So I have an Alamofire request coming in like this JSON object:
{
fieldname: 'photo',
originalname: 'pic',
encoding: '7bit',
mimetype: 'image/jpg',
buffer: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 02 01 00 48 00 48 00 00 ff e1 3e cc 45 78 69 66 00 00 4d 4d 00 2a 00 00 00 08 00 06 01 12 00 03 00 00 00 01 00 03 ... 5093173 more bytes>,
size: 5093223
}
I have a function 'uploadFile' seen below:
function uploadFile(file) {
const fileStream = fs.createReadStream(file.path);
const uploadParams = {
Bucket: bucketName,
Body: fileStream,
Key: file.filename,
};
return s3.upload(uploadParams).promise();
}
I need to pass the Buffer into the uploadFile function, but for some reason I keep getting an error that says 'TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined.'
I've tried passing in request.buffer, and Buffer.from(request.buffer). Not sure what else to try, but Buffer.isBuffer(request.buffer) returns true so I'm not sure what to do here.