All files / server/api s3.ts

0% Statements 0/7
100% Branches 0/0
100% Functions 0/0
0% Lines 0/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                                                 
import * as aws from 'aws-sdk';
 
aws.config.update({
  secretAccessKey: 'LtVZAlIhb3YgzPehQ7jp4nwoHCDEdcfZb0R6dPES',
  accessKeyId: 'AKIAJGXWAYK5HLIZAPPA',
  region: 'us-east-2',
});
 
const s3 = new aws.S3();
 
const uploadReadableStream = async (stream: any) => {
  const params = {
    Bucket: 'kukr',
    ACL: 'public-read',
    Key: Date.now().toString(),
    Body: stream,
    CacheControl: 'max-age=604800',
  };
  return s3.upload(params).promise();
};
 
const upload = async (readableStream: any) =>
  uploadReadableStream(readableStream);
export default upload;