Commit 4821aa6c251a1a2eb4f1fac7bf0f2897a435b48b
1 parent
a699ebdb
Exists in
master
and in
4 other branches
skip protection to aws3
Showing
2 changed files
with
5 additions
and
2 deletions
Show diff stats
app/controllers/files_controller.rb
| 1 | class FilesController < ApplicationController | 1 | class FilesController < ApplicationController |
| 2 | def download | 2 | def download |
| 3 | uploader = Note.find(params[:id]).attachment | 3 | uploader = Note.find(params[:id]).attachment |
| 4 | - uploader.retrieve_from_store!(params[:filename]) | ||
| 5 | send_file uploader.file.path, disposition: 'attachment' | 4 | send_file uploader.file.path, disposition: 'attachment' |
| 6 | end | 5 | end |
| 7 | end | 6 | end |
app/uploaders/attachment_uploader.rb
| @@ -21,6 +21,10 @@ class AttachmentUploader < CarrierWave::Uploader::Base | @@ -21,6 +21,10 @@ class AttachmentUploader < CarrierWave::Uploader::Base | ||
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | def secure_url | 23 | def secure_url |
| 24 | - "/files/#{model.class.to_s.underscore}/#{model.id}/#{file.filename}" | 24 | + if self.class.storage == CarrierWave::Storage::File |
| 25 | + "/files/#{model.class.to_s.underscore}/#{model.id}/#{file.filename}" | ||
| 26 | + else | ||
| 27 | + url | ||
| 28 | + end | ||
| 25 | end | 29 | end |
| 26 | end | 30 | end |