I have an issue with the Minio presigned url , I've been able to get the url and to use the PUT method to insert my file into my Minio bucket but i could not open it especially when it is a jpg , a png or a pdf file because it's automatically modified by Minio who adds a header and a footer to the file what makes it unreadable as an image
exemple of header :
----------- 591397828093304071314847
Content-Disposition: form-data; name="file"; filename="y.png"
Content-Type: image/png
Here's what i got when i download it using the presignedGetObject the problem is with the metadata added by minio.
I'm using Nodejs , here is my code :
service.js:
exports.presignedurl = async (filename) => {
return await minioClient.presignedPutObject(
process.env.MINIO_BUCKET,
filename
);
};
exports.getpresignedurl = async (filename) => {
return await minioClient.presignedGetObject(
process.env.MINIO_BUCKET,
filename,
24 * 60 * 60
);
};
controller.js
exports.presignedurl = async (req = null, res = null) => {
try {
let filename = req.query.filename;
let result = await StorageService.presignedurl(filename);
res.status(200).json(result);
} catch (err) {
res.status(405).send({ error: err.message, code: err.code });
}
};
exports.getpresignedurl = async (req = null, res = null) => {
try {
let filename = req.query.filename;
let result = await StorageService.getpresignedurl(filename);
res.status(200).json(result);
} catch (err) {
res.status(405).send({ error: err.message, code: err.code });
}
};
CodePudding user response:
The key in this case is how the file is uploaded from the postman. While uploading the file, you need to use Body > Binary > Select File, rather than using the Body > Form-Data.