Skip to content

kaskadi/files-api

Repository files navigation

GitHub Actions workflows status

Deploy status Build status Docs generation status

CodeClimate


API endpoints

The origin and root path for this API is: https://api.klimapartner.net/files

The following endpoints are defined in this API:

/

Supported methods:

GET (target lambda → get-files)

Description:

This endpoint allows user to retrieve the list of files located at a given path inside of Kaskadi's public AWS S3 bucket.

Authorization:

Type Identity source
Cognito
  • method.request.header.Authorization

Query string parameters:

Key Default Description
path / Path from where we would like to list files.

Request body:

No body found for this method.

Examples:

Example #1

Request:

GET https://api.klimapartner.net/files/?path=modules

Headers:
  Authorization: Bearer COGNITO_ACCESS_TOKEN

Response:

Status code:
  200

Headers:
  Access-Control-Allow-Origin: *

Body:
  [
    {
      "type": "folder",
      "size": 0,
      "lastModified": "2020-01-14T15:07:20.000Z",
      "path": "modules/@kaskadi/"
    },
    {
      "type": "folder",
      "size": 6272,
      "lastModified": "2020-01-14T15:20:06.000Z",
      "path": "modules/@webcomponents/"
    },
    {
      "type": "folder",
      "size": 0,
      "lastModified": "2020-03-09T07:30:12.000Z",
      "path": "modules/lit-element/"
    },
    {
      "type": "folder",
      "size": 0,
      "lastModified": "2020-03-09T07:30:13.000Z",
      "path": "modules/lit-html/"
    }
  ]
Example #2

Request:

GET https://api.klimapartner.net/files/?path=modulezzz

Headers:
  Authorization: Bearer COGNITO_ACCESS_TOKEN

Response:

Status code:
  404

Headers:
  Access-Control-Allow-Origin: *

Body:
  {
    "message": "No files found under modulezzz/"
  }

/get-signed-url

Supported methods:

GET (target lambda → get-signed-url)

Description:

This endpoint provides a way for users to get signed URLs that allows them to upload content into Kaskadi's public AWS S3 bucket.

Authorization:

Type Identity source
Cognito
  • method.request.header.Authorization

Query string parameters:

Key Default Description
key Key of the item you would like to upload on S3. Uses / as a separator to define pseudo-folder structure to create on S3. This parameter is required!

Request body:

No body found for this method.

Examples:

Example #1

Request:

GET https://api.klimapartner.net/files/get-signed-url?key=imgs/apple.png

Headers:
  Authorization: Bearer COGNITO_ACCESS_TOKEN

Response:

Status code:
  200

Headers:
  Access-Control-Allow-Origin: *

Body:
  {
    "presignedUrl": "https://some.signed.url/to/upload/file?where=in_cdn",
    "imgUrl": "https://cdn.klimapartner.net/imgs/apple.png"
  }
Example #2

Request:

GET https://api.klimapartner.net/files/get-signed-url

Headers:
  Authorization: Bearer COGNITO_ACCESS_TOKEN

Response:

Status code:
  400

Headers:
  Access-Control-Allow-Origin: *

Body:
  {
    "message": "Please provide a key parameter in your query string for the key of the file you would like to upload."
  }

API resources

The following lambda functions are used in this API:

The following layers are used in this API:

get-files

Name Sources Timeout Handler Layers
get-files
  • HTTP (GET)
default handler

See configuration file for more details.

get-signed-url

Name Sources Timeout Handler Layers
get-signed-url
  • HTTP (GET)
default handler

See configuration file for more details.

files-api-layer

Description

Layer for files-api

Dependencies

  • aws-sdk, version: 2.771.0 (see on NPM)
  • files-api-utils (local utility)

See configuration file for more details.

Stack tags

You can use any tags (and their respective values) visible below to find ressources related to this stack on AWS. See here for more details.

Tag Value
app kaskadi
service files-api
logical-unit files
type http

About

API to manage files in S3

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •