Last active
December 29, 2017 13:49
-
-
Save maticzav/869284531280470ef84379fd17f3680b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/index.ts | |
import { S3 } from 'aws-sdk' | |
// Creates S3 client | |
const s3client = new S3({ | |
accessKeyId: process.env.S3_KEY, | |
secretAccessKey: process.env.S3_SECRET, | |
params: { | |
Bucket: process.env.S3_BUCKET | |
} | |
}) | |
// src/modules/fileApi.ts | |
// Uploads a file to S3 | |
const response = await s3.upload({ | |
Key: secret, | |
ACL: 'public-read', | |
Body: part, | |
ContentLength: size, | |
ContentType: contentType | |
}).promise() | |
// Saves untraceable url for database synchronisation | |
const url = response.Location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment