dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

Fetching (long?) url including a timestamp

Open did opened this issue 10 years ago • 4 comments

Hi,

Considering this valid url with a trailing timestamp.

url = "http://assets.locomotivehosting.com/sites/50be335cc221fd000200003d/content_entry50be34e8c221fd00020000ae/50be34f9c221fd00020000c5/files/quisommesnous.jpg?1404899540"
 ::Dragonfly.app.fetch_url(url).url

will return

 => "/images/dynamic/W1siZnUiLCJodHRwOi8vYXNzZXRzLmxvY29tb3RpdmVob3N0aW5nLmNvbS9zaXRlcy81MGJlMzM1Y2MyMjFmZDAwMDIwMDAwM2QvY29udGVudF9lbnRyeTUwYmUzNGU4YzIyMWZkMDAwMjAwMDBhZS81MGJlMzRmOWMyMjFmZDAwMDIwMDAwYzUvZmlsZXMvcXVpc29tbWVzbm91cy5qcGc%2FMTQwNDg5OTU0MCJdXQ/quisommesnous.jpg?sha=262a7743"

Unfortunately, if I try to display this url, it won't work because of the "%2F" characters which is translated into "/" by Rails. So, the Dragonfly rack won't be able to catch the url.

If I remove the protocol + domain name of the url, it works, I mean I don't have the %2F characters.

 url = "/sites/50be335cc221fd000200003d/content_entry50be34e8c221fd00020000ae/50be34f9c221fd00020000c5/files/quisommesnous.jpg?1404899540"
 ::Dragonfly.app.fetch_url(url).url

will return

  =>"/images/dynamic/W1siZnUiLCIvc2l0ZXMvNTBiZTMzNWNjMjIxZmQwMDAyMDAwMDNkL2NvbnRlbnRfZW50cnk1MGJlMzRlOGMyMjFmZDAwMDIwMDAwYWUvNTBiZTM0ZjljMjIxZmQwMDAyMDAwMGM1L2ZpbGVzL3F1aXNvbW1lc25vdXMuanBnPzE0MDQ4OTk1NDAiXV0/quisommesnous.jpg?sha=d2af5309"

Any ideas? Thanks!

Did

did avatar Jul 10 '14 11:07 did

ah that's annoying. I'll need to think about it, but in the meantime you can change the url_format

url_format "/images/dynamic/:name"

so that the job string is in the GET parameters - then hopefully Rails won't convert it

markevans avatar Jul 10 '14 12:07 markevans

thanks @markevans ! Will it work efficiently with the url_host option? (I use a CDN).

did avatar Jul 10 '14 12:07 did

yeh should do

markevans avatar Jul 10 '14 13:07 markevans

I've applied your workaround in production, works great! Thanks @markevans :-)

did avatar Jul 10 '14 14:07 did