1

I have an area on my site where a user can upload files to the server. The files are not restricted to the type of file. Everything works in Firefox etc, but safari tries to open the file in a new window resulting in gibberish for filetypes it does not understand. I can "save linked file" and everything works fine. However for usability I want the file to download automatically when the link is clicked. I used carrierwave to upload the files.

Here is what My link looks like

<%= link_to document.name,"#{document.file}"%>
4

1 に答える 1

0

@Stefan はコメントでこれに答えました。

Gemfileで:

gem 'mime-types'

Carrierwave によって生成されたアップローダ ファイル内:

require 'carrierwave/processing/mime_types'

class MyUploader < CarrierWave::Uploader::Base
  include CarrierWave::MimeTypes

  process :set_content_type
end
于 2012-07-08T14:26:18.257 に答える