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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠