I have application server written in Node.js which upload files to AWS S3 storage. For that I'm using https://www.npmjs.com/package/aws-sdk and when I'm connecting to and uploading to my AWS production storage it is working fine. However during development I want to upload files to local MinIO server (create from docker image https://hub.docker.com/r/minio/minio/):
docker run -p 9000:9000 -p 9001:9001 \
quay.io/minio/minio server /minio --console-address ":9001"
MinIO server itself is working fine, I'm able to login there locally, create buckets, etc. However when I tried to upload file to my local MinIO storage using AWS SDK for node.js I'm unable to do so:
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
#s3Client = new S3Client({
credentials: {
accessKeyId: config.getAwsStorageAccessKeyId(), // from env variables
secretAccessKey: config.getAwsStorageSecretAccessKey(),
},
...(globalConfig.isReleaseVersion() && {
endpoint: config.getAwsStorageEndpoint(), // from env "http://localhost:9001"
}),
});
And later I'm trying to upload object:
await this.#s3Client.send(new PutObjectCommand({
Bucket: config.getAwsStorageWebflowBucketName(), // from env "test" value
Key: 'example.json',
Body: body, // a buffer
}));
I'm receiving error:
ERROR EndpointError: Custom endpoint `test.127.0.0.1://9001/` was not a valid URI
However I'm able to reach address http://test.localhost:9001/ from my browser. When I try to pass directly value 'http://localhost:9001/'
as an endpoint to S3Client
configuration, I'm getting error:
ERROR Error: getaddrinfo ENOTFOUND test.localhost
Looks like port value is ignored my SDK. How can this be fixed?
<Yes, I know there is separate MinIO SDK - I want to use one provided by AWS, existence of endpoint
parameter in configuration implies that it should be possible>
ERROR Error: getaddrinfo ENOTFOUND test.localhost
- port is still missing – Maquis