minio-js icon indicating copy to clipboard operation
minio-js copied to clipboard

presignedUrl metada adding bug? and a dirty fix :)

Open mobulaco opened this issue 4 years ago • 1 comments

Hello,

I couldn't get success to set any metadata with presignedUrl/presignedPutUrl and couldn't found how to.

While digging, I realized that the preSignedUrl doesn't pass any header parameters to getRequestOptions;

This is just my quick dirty fix, sorry for that, I am just trying to write a fast PoC for my potential customer. O:-)

In presignedUrl method:

let headers=reqParams.headers || {}; delete reqParams.headers; var query = querystring.stringify(reqParams);

and

var reqOptions = this.getRequestOptions({method, headers, region, bucketName, objectName, query})

This is the sample code: (metadata sent through reqParams parameter of presignedUrl method)

var minioClient = require('./client');

var metaData = { 'Content-Type': 'text/plain', 'x-amz-meta-mahmut': 'tuncer kolonyasi' }

minioClient.presignedUrl('PUT','mobulaco', 'hello2.txt', 246060, { headers:{ 'x-amz-meta-mahmut': 'tuncer kolonyasi' } }, function(err, presignedUrl) { if (err) return console.log(err); let headers=""; for (var a in metaData) headers+=" -H '"+a+":"+metaData[a]+"'"; console.log("curl -X PUT "+headers+" --data-binary '@./deneme.txt' '"+presignedUrl+"'"); });

Thanks.

mobulaco avatar Sep 29 '21 06:09 mobulaco

Minio JS ideally would support setting metadata on presignedPut, go client seems to support it

chris-aeviator avatar Jun 13 '23 10:06 chris-aeviator