Skip to content

Instantly share code, notes, and snippets.

@shairontoledo
Created November 30, 2020 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shairontoledo/745d3927b9108fe473350333c7f0a692 to your computer and use it in GitHub Desktop.
Save shairontoledo/745d3927b9108fe473350333c7f0a692 to your computer and use it in GitHub Desktop.

Files

It's wrapper project designed to manage user's files.

Buckets mapping:

Environment Bucket Name
qa staypuft-item-images
staging neat-images-staging
production neat-images-prod

Files API

Supports following file artifact names:

  • invoice-logo

Resource:

GET /files/:name/uploadUrl

An AWS S3 presigned url scoped by account id will be returned.

Request URL parameters:

  • :name - The artifact name.
  • mime-type - The MIME Type of the file that will be uploaded. Headers: Authorization: Bearer {jwt token}

Request Example:

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5c...' 'https://storage.neat.com/files/invoice-logo/uploadUrl?mime-type=image/jpeg'

Response example:

{
  "uploadUrl": "https://neat-images-prod.s3.amazonaws.com/5fc571126678c20027017748/files/invoice-logo?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQV64PZNHZPEHRBTA%2F20201130%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201130T222622Z&X-Amz-Expires=900&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Security-Token=IQoJb3JpZ2l..."
}

Errors:

  • Unsupported artifact name

Resource:

GET /files/:name/downloadUrl

An AWS S3 presigned url to download the file.

Request URL parameters:

  • :name - The artifact name.will be uploaded.

Headers: Authorization: Bearer {jwt token}

Request Example:

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5c...' 'https://storage.neat.com/files/invoice-logo/downloadUrl'

Response example:

{
  "downloadUrl": "https://neat-images-prod.s3.amazonaws.com/5fc571126678c20027017748/files/invoice-logo?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQV64PZNHZPEHRBTA%2F20201130%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201130T222622Z&X-Amz-Expires=900&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Security-Token=IQoJb3JpZ2l..."
}

Errors:

  • Unsupported artifact name

Resource:

GET /files/:name/download

Redirect via HTTP Header Location to the presigned download url.

Request URL parameters:

  • :name - The artifact name.will be uploaded.

Headers: Authorization: Bearer {jwt token}

Request Example:

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5c...' 'https://storage.neat.com/files/invoice-logo/download'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment