Feature request: filename in URL #22

Closed
parndt opened this Issue Sep 30, 2010 · 7 comments

Comments

Projects
None yet
4 participants
@parndt
Contributor

parndt commented Sep 30, 2010

By default dragonfly urls don't end with an extension for the file they are representing e.g.:
/assets/BAhbB1sHOgZmIiMyMDEwLzA5LzAxL1NTQ19DbGllbnRfQ29uZi5qcGdbCDoGcDoKdGh1bWIiDjk0MngzNjAjYw

This causes things like lightbox scripts to fail because they are looking for extensions.

A better URL is something like this:

/system/images/BAhbB1sHOgZmIiMyMDEwLzA5LzAxL1NTQ19DbGllbnRfQ29uZi5qcGdbCDoGcDoKdGh1bWIiDjk0MngzNjAjYw/image_name.jpg

We have managed to achieve this in Refinery CMS using this wee instance_eval:
http://github.com/resolve/refinerycms/blob/master/vendor/refinerycms/images/lib/images.rb#L48-L62

It'd be nice to have core support for this, maybe as an option passed to the dragonfly configuration that puts the filename at the end by default. As it is, we have to get it using the job.steps where we look for one with step_name :fetch.

@markevans

This comment has been minimized.

Show comment Hide comment
@markevans

markevans Oct 1, 2010

Owner

Hi - there is core support for this! :)
see 'suffix' bit of http://markevans.github.com/dragonfly/file.URLs.html

Owner

markevans commented Oct 1, 2010

Hi - there is core support for this! :)
see 'suffix' bit of http://markevans.github.com/dragonfly/file.URLs.html

@parndt

This comment has been minimized.

Show comment Hide comment
@parndt

parndt Oct 1, 2010

Contributor

Ah excellent! Thanks Mark ;)

Contributor

parndt commented Oct 1, 2010

Ah excellent! Thanks Mark ;)

@oliverbarnes

This comment has been minimized.

Show comment Hide comment
@oliverbarnes

oliverbarnes Mar 21, 2011

Hey Mark, I'm trying to get the original filename on the url too, to detect it in tests... But haven't managed to use the suffix proc example on the docs. What's the proper Rails 3 route that would go with that config?

Hey Mark, I'm trying to get the original filename on the url too, to detect it in tests... But haven't managed to use the suffix proc example on the docs. What's the proper Rails 3 route that would go with that config?

@markevans

This comment has been minimized.

Show comment Hide comment
@markevans

markevans Mar 21, 2011

Owner

hi - I'm currently working on making this easier as at the moment it's a bit tricky having the original filename available at the time that you generate the url.

In the meantime, the best way is probably to pass the name in each time as a suffix
image.url(:suffix => name)
where name has been saved on your model (you can just add the attachment_name column and it should just work) and then wrap this in a helper.

if you use Rails 3 routes you'd need to have all the necessary information in the url - what kind of thing are you using it for? is it standard image thumbnails for a model attachment?

Owner

markevans commented Mar 21, 2011

hi - I'm currently working on making this easier as at the moment it's a bit tricky having the original filename available at the time that you generate the url.

In the meantime, the best way is probably to pass the name in each time as a suffix
image.url(:suffix => name)
where name has been saved on your model (you can just add the attachment_name column and it should just work) and then wrap this in a helper.

if you use Rails 3 routes you'd need to have all the necessary information in the url - what kind of thing are you using it for? is it standard image thumbnails for a model attachment?

@oliverbarnes

This comment has been minimized.

Show comment Hide comment
@oliverbarnes

oliverbarnes Mar 22, 2011

yes, image thumbs for a model attachment, only accessed from an iphone app

adding attachment_name works well :) thanks

https://gist.github.com/880522 (tried embedding but it didn't render ?)

<script src="https://gist.github.com/880522.js"> </script>

yes, image thumbs for a model attachment, only accessed from an iphone app

adding attachment_name works well :) thanks

https://gist.github.com/880522 (tried embedding but it didn't render ?)

<script src="https://gist.github.com/880522.js"> </script>
@markevans

This comment has been minimized.

Show comment Hide comment
@markevans

markevans Mar 22, 2011

Owner

cool - hopefully when I've done with the refactoring you won't need the helper :)

Owner

markevans commented Mar 22, 2011

cool - hopefully when I've done with the refactoring you won't need the helper :)

@kristm

This comment has been minimized.

Show comment Hide comment
@kristm

kristm Nov 7, 2014

Hi @markevans , any update on this feature?
Actually what I had more in mind is to get the absolute file path of a previously uploaded image

kristm commented Nov 7, 2014

Hi @markevans , any update on this feature?
Actually what I had more in mind is to get the absolute file path of a previously uploaded image

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment