The upload service is responsible for handling upload requests.
It does not process files, but it does provides the client with the needed information to upload to S3 directly.
- docs // API documentation
- src
|- controllers // maps between routes to services
|- routes // endpoint definitions
|- services // business logic
- Install npm packages.
npm install
These credentials should be associated with an account that has s3:PutObject
access to the bucket objects you would like API clients to be able to write to.
An example custom policy:
{
"Statement": [
{
"Action": [
"s3:PutObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::MyBucketNameGoesHere/*"
]
}
]
}
- Configure Sentry
If you want to use Sentry, you must pass environment variables containing the Sentry DSN and the Sentry environment that you will use for this project.
.env
export SENTRY_DSN="https://[email protected]/here"
export SENTRY_ENVIRONMENT=local
- Start the project.
npm start
- Check health.
curl localhost:3000/api/health
Should output:
{"status":"available","message":"OK"}
cp .env.example .env
and set correct AWS credentialsdocker-compose up
orsudo docker-compose up --build
to force rebuild after first run.- See http://localhost:3000/api/health
No inputs.
Returns a health check.
status
: eitheravailable
orunavailable
.message
: a more detailed explanation about the health status.
bucket
: the AWS S3 bucket the file will be passed to (e.g.permanent-local
).fileType
: the mime type of the file being uploaded (e.g.image/png
),maxSize
: the maximum file size that the destination should accept,
fileName
: the destination file name within the bucket.path
: the destination path within the bucket.
destinationUrl
: the URL that will ultimately hold the file once it has been uploaded.presignedPost
: an AWS S3 presigned post which will accept the file. This post will contain:url
: the URL that the file should be POSTed to.fields
: an array of fields which must be submitted as part of the POST body. These fields must appear before the file content itself.
Contributors to this repository agree to adhere to the Contributor Covenant Code of Conduct. To report violations, get in touch with [email protected].
Found a vulnerability? Report this and any other security concerns to [email protected].
This code is free software licensed as AGPLv3, or at your option, any final, later version published by the Free Software Foundation.