Unable to read file bytes accurately for jpeg/jpg s3 objects

0

I am using node express js and using aws-sdk v3. I am able to properly read the filebytes for png and pdf files using the below code. But whenever I try to get the file bytes for jpg or jpeg s3 files, it doesnt return the SOI marker. Is there a way to be able to read the jpg/jpeg file bytes accurately?

const getObjectCommand = new GetObjectCommand({
Bucket: bucket,
Key: object.Key,
});
const getObjectResponse = await s3Client.send(getObjectCommand);
const fileBytes = await new Promise((resolve, reject) => {
const chunks = [];
getObjectResponse.Body.on("data", (chunk) => chunks.push(chunk));
getObjectResponse.Body.on("end", () => resolve(Buffer.concat(chunks)));
getObjectResponse.Body.on("error", (error) => reject(error));
});
已提問 8 個月前檢視次數 172 次
1 個回答
1
profile picture
已回答 8 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南