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));
});
posta 8 mesi fa172 visualizzazioni
1 Risposta
1
profile picture
con risposta 8 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande