I want to upload a file to minio, but when I run it I get an error like this
TypeError: metaData should be of type "object"
at Client.fPutObject (/Users/berliana/Documents/nodejs-simple-file-upload/node_modules/minio/dist/main/minio.js:1210:15)
at Client.<anonymous> (/Users/berliana/Documents/nodejs-simple-file-upload/node_modules/minio/dist/main/helpers.js:74:51)
at /Users/berliana/Documents/nodejs-simple-file-upload/server.js:51:17
at Layer.handle [as handle_request] (/Users/berliana/Documents/nodejs-simple-file-upload/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/berliana/Documents/nodejs-simple-file-upload/node_modules/express/lib/router/route.js:137:13)
at Immediate._onImmediate (/Users/berliana/Documents/nodejs-simple-file-upload/node_modules/multer/lib/make-middleware.js:53:37)
at processImmediate (node:internal/timers:466:21)
this is my code
var minioClient = new minio.Client({
endPoint: 'play.min.io',
port: 9000,
useSSL: true,
accessKey: 'myaccesskey',
secretKey: 'mysecretkey'
});
app.post("/uploadfile", multer({dest: "./uploads/"}).single("files"), function(request, response) {
minioClient.fPutObject("berliana", request.file.originalname, request.file.path, "application/octet-stream", function(error, etag) {
if(error) {
return console.log(error);
}
response.send(request.file);
});
});
Help me solve this
pass the metadata as an object (as indicated by the error):
minioClient.fPutObject("berliana", request.file.originalname, request.file.path, {"Content-Type": "application/octet-stream"}, function(error, etag) {
if(error) {
return console.log(error);
}
response.send(request.file);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.