set content-type when uploading image
This commit is contained in:
parent
2ee4f3197d
commit
bfbbf4836b
|
|
@ -25,13 +25,15 @@ export const s3 = singleton("s3-client", () => {
|
|||
|
||||
export const s3uploadFile = async (
|
||||
filename: string,
|
||||
file: PutObjectRequest["Body"] | string | Buffer
|
||||
file: PutObjectRequest["Body"] | string | Buffer,
|
||||
contentType?: string
|
||||
) => {
|
||||
await s3.send(
|
||||
new PutObjectCommand({
|
||||
Bucket: S3_BUCKET_NAME,
|
||||
Key: filename,
|
||||
Body: file,
|
||||
ContentType: contentType,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export const action: ActionFunction = async ({ request }) => {
|
|||
}
|
||||
const buffer = Buffer.concat(chunks)
|
||||
const filename = `${user.id}/${nanoid()}.jpg`
|
||||
await s3uploadFile(filename, buffer)
|
||||
await s3uploadFile(filename, buffer, "image/jpeg")
|
||||
return filename
|
||||
}
|
||||
const formData = await unstable_parseMultipartFormData(request, uploadHandler)
|
||||
|
|
|
|||
Loading…
Reference in New Issue