Skip to content

Conversation

@bexsoft
Copy link
Collaborator

@bexsoft bexsoft commented Dec 14, 2021

What does this do?

Implements a new exclusive API to retrieve metadata information without requesting the full list of objects from a bucket

How does it look?

Screen Shot 2021-12-13 at 18 53 01

Screen Shot 2021-12-13 at 18 52 53

Signed-off-by: Benjamin Perez [email protected]

@prakashsvmx
Copy link
Member

prakashsvmx commented Dec 14, 2021

@bexsoft
A minor observations:

  1. sometimes the api is called without prefix .

Steps to replicate:
Click on Buckets -> Browse -> Click on an Object -> Click on Buckets again -> Click on Browse again on a bucket
Observe the network tab.

image

  1. I think we need to decodeURIComponent of the metadata value. Because non ascii characters can be sent as url encoded which needs to be rendered in UI accordingly. ( Kindly correct me if i am missing something here)
//ObjectDetails.tsx : Line 172 
 const renderItem = Array.isArray(
                                metadata[element]
                              )
                                ? metadata[element]
                                    .map(decodeURIComponent)
                                    .join(", ")
                                : decodeURIComponent(metadata[element]);
Sample code For testing with minio-js
// Upload a stream
var file = '/home/Pictures/error.png'
var fileStream = Fs.createReadStream(file)
Fs.stat(file, function(e, stat) {
  if (e) {
    return console.log(e)
  }
  s3Client.putObject('test-bucket-2', 'test-meta-data.png', fileStream, stat.size, {
    "ascii": "AMAZONS3",
    "ascii1": "AMAZONS3",
    "nonascii": encodeURIComponent("ÄMÄZÕÑ S3")
  }, function(e) {
    if (e) {
      return console.log(e)
    }
    console.log("Successfully uploaded the stream")
  })
})

@bexsoft
Copy link
Collaborator Author

bexsoft commented Dec 14, 2021

@bexsoft A minor observations:

  1. sometimes the api is called without prefix .

Steps to replicate: Click on Buckets -> Browse -> Click on an Object -> Click on Buckets again -> Click on Browse again on a bucket Observe the network tab.

image

  1. I think we need to decodeURIComponent of the metadata value. Because non ascii characters can be sent as url encoded which needs to be rendered in UI accordingly. ( Kindly correct me if i am missing something here)
//ObjectDetails.tsx : Line 172 
 const renderItem = Array.isArray(
                                metadata[element]
                              )
                                ? metadata[element]
                                    .map(decodeURIComponent)
                                    .join(", ")
                                : decodeURIComponent(metadata[element]);

Sample code For testing with minio-js

// Upload a stream
var file = '/home/Pictures/error.png'
var fileStream = Fs.createReadStream(file)
Fs.stat(file, function(e, stat) {
  if (e) {
    return console.log(e)
  }
  s3Client.putObject('test-bucket-2', 'test-meta-data.png', fileStream, stat.size, {
    "ascii": "AMAZONS3",
    "ascii1": "AMAZONS3",
    "nonascii": encodeURIComponent("ÄMÄZÕÑ S3")
  }, function(e) {
    if (e) {
      return console.log(e)
    }
    console.log("Successfully uploaded the stream")
  })
})

Good catch @prakashsvmx! Thank you!

Committed suggestions

Copy link
Member

@prakashsvmx prakashsvmx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested. LGTM. 👍

@bexsoft bexsoft merged commit dd488e4 into minio:master Dec 15, 2021
@bexsoft bexsoft deleted the api-replacement branch December 15, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants