-
|
It is not possible to pass the path to the send_file(
resume.file.to_io.path
)I want to use the In all environments except for |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Yeah, the memory storage cannot retrieve the path, because the uploaded file doesn't exist on the filesystem. You'll need to create a conditional for memory storage, something like: class ApplicationController < ActionController::Base
private
def send_upload(uploaded_file, ...)
if uploaded_file.storage.is_a?(Shrine::Storage::Memory)
send_file uploaded_file.download.path, ...
else
send_file uploaded_file.to_io.path, ...
end
end
end# in your controller:
send_upload(resume.file)You could also use |
Beta Was this translation helpful? Give feedback.
-
|
@janko thank you for the quick response, seems like that's the only way to do it. That's what I did: send_upload(
file,
type: inline ? 'application/pdf' : 'application/force-download',
disposition: inline ? :inline : :attachment,
filename: "#{sanitize_filename(filename)}.pdf"
)
end
private
def send_upload(uploaded_file, **options)
if uploaded_file.storage.is_a?(Shrine::Storage::Memory)
send_file uploaded_file.download.path, **options
else
send_file uploaded_file.to_io.path, **options
end
end |
Beta Was this translation helpful? Give feedback.
Yeah, the memory storage cannot retrieve the path, because the uploaded file doesn't exist on the filesystem. You'll need to create a conditional for memory storage, something like:
You could also use
send_data uploaded_file.read, ...for the memory storage path.