Minio/S3 weird URL

Hi there,

First of all thanks for Shrine! I moved from Carrierwave and so far I am more than happy.

I recently switched to Minio and now I am restructuring my app, I am uploading to Minio and this works fine. The problem begins when I am calling _url … Apparently instead of:

https://cdn.mydomain.com/example.jpg

I receive:

https://cdn.mydomain.com/example.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=123123213123123&X-Amz-Date=20191116T223451Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=123123213123123

The URL would work fine with only the example.jpg but is not working with all the query params.

I am not sure if this is caused by Minio (the bucket policy seems to be set up properly) or if this is Shrine specific.

My goal is simply to get rid of all the query params, since they are not needed and cause problems. The files are publicly available and I am not sure where the query params come from.

Any help is greatly appreciated :slight_smile:

Edit:

I noticed that the problem where the image is not available at all comes from having a different url_options store host compared to the s3 endpoint. I also found out that the minio console gives me the same URL when I use their share functionality, I am just wondering how I change that, because the URL is expiring after X days, so I need a permanent URL without all those query params…

Hello Nik,
It seems your files are stored privately. It is by default, but you can create a public store :

Shrine.storages = {
cache: Shrine::Storage::S3.new(prefix: “cache”, **s3_options),
store: Shrine::Storage::S3.new(**s3_options),
public_store: Shrine::Storage::S3.new(public: true, upload_options: { cache_control: “public, max-age=15552000” }, **s3_options)
}

I think public: true is what does the trick.
If all your files are public I guess you can change the default store setup too.

1 Like

Cool cool, that did the trick.

Thanks so much!