2

Hello everyone i have bucket in minio server and bucket name is 'geoxing' and geoxing have directory img/site. i want to upload picture in site directry using nodejs. below is code and i am getting error Invalid bucket name: geoxing/img/site. how can i solve this error. thanks

savefile() {
    const filePath = 'D://repositories//uploads//geoxing//site//b57e46b4bcf879839b7074782sitePic.jpg';
const bucketname = 'geoxing/img/site'
    var metaData = {
      'Content-Type': 'image/jpg',
      'Content-Language': 123,
      'X-Amz-Meta-Testing': 1234,
      example: 5678,
    };
    this.minioClient.fPutObject(
      bucketname,
      'b57e46b4bcf879839b7074782sitePic.jpg',
      filePath,
      metaData,
      function (err, objInfo) {
        if (err) {
          return console.log(err);
        }
        return console.log('Success', objInfo.etag);
      },
    );
  }
umer
  • 49
  • 2
  • 8

1 Answers1

2

In Amazon S3 and Minio:

  • Bucket should just be the name of the bucket (eg geoxing)
  • Key should include the full path as well as the filename (eg img/site/b57e46b4bcf879839b7074782sitePic.jpg)

Amazon S3 and Minio do not have 'folders' or 'directories' but they emulate directories by including the path name in the Key. Folders do not need to be created prior to uploading to a folder -- they just magically appear when files are stored in that 'path'.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Hi sir, i want to upload local directry to minio that contains multiple files. like gexoing is folder and i want to upload whole folder by using nodejs. how can i do it – umer Sep 26 '22 at 05:38
  • @umer The API calls only allow **one** file to be uploaded at a time. Therefore, the code would need to **loop** through all the files, uploading each one individually. This might be helpful: [Upload entire directory tree to S3 using AWS sdk in node js](https://stackoverflow.com/q/27670051/174777) – John Rotenstein Sep 26 '22 at 06:03
  • Yes, this is really helpful. i solve the problem. thanks – umer Sep 26 '22 at 08:14