mercredi 25 février 2015

Paperclip route file with dots in name

I have the following route:



resources :projects do
resources :uploads, :only => [:destroy] do
member do
get ':filename', to: :download, as: :download
end
end
end

download_project_upload GET /projects/:project_id/uploads/:id/:filename(.:format) uploads#download


Here's the relevant part of my upload model



class Upload
has_attached_file :item,
:url => "/projects/:project_id/uploads/:id/:style_:basename.:extension",
:path => ":rails_root/public/:class/:attachment/:id/:style_:basename.:extension"


The problem is when I go a URL like the following:



http://mysite/projects/3902/uploads/5634/some.file.withdots.pdf


I get a routing error. How can I resolve this? The route looks correct to me.


Note: I only get the routing error on files which have dots in the names. If the file has no dots or uses underscores the route resolves as expected. Renaming all filenames to parse the dots out is not an option.


Aucun commentaire:

Enregistrer un commentaire