我有一个主机-192.168.200.x1,其中Minio运行在Docker中。我用这个命令- docker run --name minio_server --hostname minio -d -p 9000:9000 -p 9001:9001 minio/minio server /data --console-address ":9001"启动了minio。因此,我有另一个带有NodeJS代码的主机192.168.200.xx2,我试图从它向minio发送数据。这是我的NodeJS代码:
async function uploadImage(req, res) {
const path = await image_functions_1.ImageLoad.urlCreate(userId, surveyId) + "/" + req.file.originalname;
return res.status(200).json({ success: false, message: "Failed to upload!" });
let minioClient = new Minio.Client({
endPoint: process.env.MINIO_END_POINT,
port: 9000,
useSSL: false,
accessKey: process.env.MINIO_ACCESS_KEY,
secketKey: process.env.MINIO_SECRET_KEY
});
minioClient.putObject(process.env.MINIO_BUCKET, path, req.file.buffer, function (err, etag) {
if (err) {
return console.log(err);
}
});当我试图将数据从JS发送到Minio时,会出现以下错误:
(node:14441) UnhandledPromiseRejectionWarning: InvalidEndpointError: Invalid endPoint : http://192.168.200.xx1
at new Client (/home/moxem/backend/node_modules/minio/dist/main/minio.js:102:13)
at uploadImage (/home/moxem/backend/dist/api/Media/image_crud.js:34:23)
at processTicksAndRejections (internal/process/task_queues.js:97:5)endPoint在.env文件中的值是:MINIO_END_POINT=http://192.168.xxx.xx1。另外,我试图将值更改为minio:MINIO_END_POINT=minio://192.168.200.xx1的主机名。但同样的错误出现了。在主机192.168.200.x1中,我还通过sudo ufw allow 9000打开了minio端口。我做错了什么?
发布于 2022-08-09 15:45:03
生成的客户端配置应该如下所示
// so http:// needs to be removed from endpoint.
var s3Client = new Minio.Client({
useSSL: false,
endPoint: "localhost",
port: 9000,
accessKey: "minio",
secretKey: "minio123"
})
//with hosted play instance.
let s3Client =new Minio.Client({
endPoint: 'play.min.io',
port: 9000,
useSSL: true,
accessKey: 'Q3AM3UQ867SPQQA43P2F',
secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG'
})
因此,需要将http://从端点中删除。
https://stackoverflow.com/questions/73286800
复制相似问题