How to specify metadata filename for downloaded file? #683
Answered
by
adam12
aaricpittman
asked this question in
Q&A
-
I have an ActiveRecord model that has an attachment named class Image < ApplicationRecord
include ImageUploader::Attachment(:file)
end What is the correct way to set that attachment when creating a new instance of the model using a file downloaded remotely and specifying the metadata filename? Doing the following handles the file but because it is not a Image.create(file: Down.open("https://example.org/file")) |
Beta Was this translation helpful? Give feedback.
Answered by
adam12
Apr 3, 2024
Replies: 1 comment 1 reply
-
Untested, but you might need to go directly through the attacher for this. url = "https://example.org/file"
image = Image.new
image.file_attacher.attach(Down.open(url), metadata: { filename: File.basename(url) }) Alternatively the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
aaricpittman
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Untested, but you might need to go directly through the attacher for this.
Alternatively the
remote_url
plugin?