minio-js
minio-js copied to clipboard
Bug: sns response key
Under Records[0].s3.object.key
, the /
is being escaped to %2F
. If I try to do a GET operation with minio sdk that requires this key, it will return S3Error: Not found
NOTE: the aws sdk returns this field with a slash.
I only added the relevants fields as an example
{"EventName":"s3:ObjectCreated:Post","Key":"","Records":[{"eventVersion":"2.0","eventSource":"minio:s3","awsRegion":"","eventTime":"","eventName":"s3:ObjectCreated:Post","userIdentity":{"principalId":""},"requestParameters":{"principalId":"","region":"","sourceIPAddress":""},"responseElements":{"x-amz-request-id":"","x-minio-deployment-id":"","x-minio-origin-endpoint":""},"s3":{"s3SchemaVersion":"1.0","configurationId":"","bucket":{"name":"","ownerIdentity":{"principalId":""},"arn":""},"object":{"key":"users%2FA644798CEC-FDF5884FEAB5%2Fdee9834d9a7bc8df438183e171cbd2","size":132,"eTag":"","contentType":"image/png","userMetadata":{"X-Amz-Meta-Id-Pod":"0","X-Amz-Meta-Id-Session":"c6de5991-199c","X-Amz-Meta-Source":"1","content-type":"image/png"},"sequencer":""}},"source":{"host":"","port":"","userAgent":""}}]}
We will investigate this.
dcodeURIComponent("users%2FA644798CEC-FDF5884FEAB5%2Fdee9834d9a7bc8df438183e171cbd2")- you could use this in case
looks like an upstream dependency bug for the nested json decoding.
I'll close the issue because it is not directly related with minio-js library.
The listenBucketNotification
function looks to be working correctly but I'm not using it. The s3.object.key should come url enconded like it is.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html
The s3 key provides information about the bucket and object involved in the event. The object key name value is URL encoded. For example, "red flower.jpg" becomes "red+flower.jpg" (Amazon S3 returns "application/x-www-form-urlencoded" as the content type in the response).
https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html
const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/+/g, ' '));