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));
});
gefragt vor 8 Monaten172 Aufrufe
1 Antwort
1
profile picture
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen