Closed ChiKaLiO closed 2 years ago
@ChiKaLiO I do not see anything wrong with your code. But without knowing much about how sharp works, maybe the call is meant to be async or you might want to just pass in the file stream into sharp vs the entire file obj
E.g.
// Async stuff
const resolveMetadata = (req, file) => {
return new Promise((resolve, reject) => {
sharp(file).resize(1000).webp({ quality: 80 }, { progressive: true, force: false })
.then((metadata) => resolve(metadata))
.catch((error) => reject(error));
});
};
// Stream stuff
const resolveMetadata = (req, file) => {
return new Promise((resolve, reject) => {
const metadata = sharp(file.stream).resize(1000).webp({ quality: 80 }, { progressive: true, force: false });
resolve(metadata);
});
};
Are you still having this issue or did you figure it out?
Closing for now due to no response from @ChiKaLiO
Feel free to re-open if this comes up again
This is question more then an issue I've spent the last 8 hours trying to figure it out..
const resolveMetadata = (req, file) => { return new Promise((resolve, reject) => { const metadata = sharp(file).resize(1000) .webp({quality: 80},{ progressive: true, force: false }); resolve(metadata); }); };
it just wont work lol !
console.log(file)
prints null so i can't figure anything ðŸ˜