I am trying to upload images to a s3 bucket from react app. It's purely frontend and I am not passing any to/from backend. This is my function that uploads file:
function uploadfile(fileName, selectedfile) {
const params = {
Bucket: "mks-sample-bucket",
Key: fileName,
Body: Buffer.from(selectedFile, "binary"),
ContentType: file.type,
};
return bucket.upload(params, function (err, data) {
if (err) {
console.log("There was an error uploading your file: ", err);
return false;
}
console.log("Successfully uploaded file.", data);
return true;
});
}
This is the error I am getting "Uncaught TypeError: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type object".
I am not sure why I am getting this issue.