I can successfully upload image files, but when access the image URL directly it will download instead of display in the browser. I checked the file type, it’s ‘multipart/form-data’ instead of ‘image/xxx’
Here’s my code:
generate the persignedUrl:
const putObjectCommandProps = {
Bucket : configs.bucketName,
Key : putObjectKey,
ContentType: objContentType, // this is the file type e.g. 'image/png'
};
const uploadSignedUrl = await getSignedUrl(
S3,
new PutObjectCommand(putObjectCommandProps),
{ expiresIn },
);
upload from frontend:
const uploadRes = await axios.put(cloudflareR2Auth.signedUrl, file, {
headers: { 'Content-Type': 'multipart/form-data' },
});