Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/models/concerns/csv2db/active_storage_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ def file=(file)
self.file_name = filename
end

def download_link(expires_in: LINK_MAX_EXPIRY)
return unless file_attachment.present?
def download_link
return unless file_attachment.present? && file_attachment.attached?

set_current_host

file_attachment.service_url(expires_in: expires_in.to_i, disposition: 'attachment')
file_attachment.service_url(
expires_in: LINK_MAX_EXPIRY.to_i,
disposition: 'attachment'
)
end

private
Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/csv2db/dragonfly_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module Csv2db::DragonflyAdapter
validate :check_file_extension
end

def download_link
file.url
end

private

def check_file_extension
Expand Down
5 changes: 1 addition & 4 deletions app/views/csv2db/_csv_import_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
%tr
%td= import.id
%td= import.created_at
- if Csv2db.config.storage_adapter.active_storage?
%td= link_to import.file_name, import.download_link
- else
%td= link_to import.file.name, import.file.url, target: '_blank'
%td= link_to(import.file_name, import.download_link)
%td
.badge{ class: "badge-upload-#{import.status}" }= import.status
%td
Expand Down