I’ve the following ts code that submit a file came from GraphQL API to my AWS S3 bucket. it works perfectly when I run the project using http lib, but when I run it using sls offline start
or from aws lambda function it uploads the file but it doesn’t open(like a damaged file) - except text files
the code:
const fileStream = data.createReadStream()
const uploadParams = {
Bucket: 'XXX',
Key: data.filename,
Body: fileStream,
ContentType: data.mimetype,
ContentEncoding: data.encoding,
ACL: 'public-read',
};
const result = await s3.upload(uploadParams).promise()
data object looks like this:
{ filename: '11083626_830419647032756_2338667058698516671_n.jpg',
mimetype: 'image/jpeg',
encoding: '7bit',
createReadStream: [Function: createReadStream] }