zoomoid / strapi-provider-upload-aws-s3-advanced

A partial fork of https://github.com/strapi/strapi to extend the S3 Upload Provider to support path prefixes inside a bucket
MIT License
26 stars 23 forks source link

Fix saved media url starting with https::// #15

Closed silviodaminato closed 2 years ago

silviodaminato commented 2 years ago

I noticed that the url of the uploaded media was saved as https:://bucket.s3.region.amazonaws.com/path/object_key (i.e.: with double colon after the url schema). I added a check to see whether it's necessary or not.

zoomoid commented 2 years ago

I really wonder why the resolved Endpoint's protocol would already contain the colon? The spec for URI schemes tells otherwise, but nonetheless thank you for your contribution regarding catching this behaviour. I will merge this as soon as I have a dev setup again.

Could you maybe also provide me with details in regards to your setup, i.e., S3 provider etc?

zoomoid commented 2 years ago

Nevermind, I dug into this myself and found this obscurity: https://github.com/aws/aws-sdk-js-v3/blob/03e589f6e1b760dc365b4ccb17f8523bab71e1fa/packages/protocol-http/src/httpRequest.ts#L24 from the Endpoint type documentation.

This being only discovered now can only be attributed to me not testing the case of not defining a CDN_BASE_URL and using the bucket url directly (after all, that's what this package is for).

Thank you for pointing this out, @silviodaminato!