Pretty location not working with download endpoint

Hi! I’m sure I’m missing something stupid…

In my uploader class I have this:

class ImageUploader < Shrine
plugin :pretty_location
plugin :download_endpoint, prefix: "images", host: "https://#{Settings.asset_host}"

Then I use the .download_url method to get the image URL including the CDN host. The download URL looks like this though:

https://cdn.mydomain.net/images/eyJpZCI6ImltYWdlLzVLRy9pbWFnZS81YWU4MmQyYTA5MzkwYTc4MDkzYTEwN2I5ZTQzNjQyZS5qcGciLCJzdG9yYWdlIjoic3RvcmUiLCJtZXRhZGF0YSI6eyJmaWxlbmFtZSI6IkRhUGljY29sbzEuanBnIiwic2l6ZSI6NTE5ODcsIm1pbWVfdHlwZSI6ImltYWdlL2pwZWcifX0

I would like to have a URL like

https://cdn.mydomain.net/images/<identifier>/filename.extension

The pretty_location plugin doesn’t seem to be working at all.

What am I missing?

Thanks!

I am trying with the generate_location method as well but the record id (identifier) is still nil at that stage because the record is not persisted yet. Is this why the plugin isn’t working properly?

I’m stupid :smiley:

If I try “Save As” the filename is correct. Nevermind :smiley:

How did you solve this issue?

I also want to return my path as:
https://cdn.mydomain.net/images/<identifier>/filename.extension

However, when I try: user.image_url
I got the unique identifier https://mybucket.s3.us-east-2.amazonaws.com/cache/users/image/4ad2263.jpg

Thanks

Hi, try with download_url - you need to configure the download endpoint.

1 Like