Closed founder3000 closed 4 years ago
I figured it out by observing the behavior of the form.
filename = 'myfile.csv'
upload = user.uploads.new
key = upload.text_file_name_key.gsub('${filename}', filename)
upload.text_file_name = File.open(filename)
upload.text_file_name_key = key
upload.save!
Works!
I use this gem for file uploads from our UI. But I have a use case for grabbing files from a remote SFTP server and creating them as Uploads (Upload is an AR object).
Upload mounts an Uploader object like so:
Then I try this:
I was always getting:
like that. So I turned off filename formatting in the initializer:
Now my upload works, but the file name is being changed to
text_file_name
.I'm not sure why the validation step is being used to set the file name. I'm worried that turning this off will also screw up the names in the UI upload.
UPDATE
Yeah that's not going to work either. It saves the file with no name on S3. Here is an example download link:
Now this download link DOES work. I'm not sure how, because there's no file name. Here's what a "healthy" link using S3 looks like:
The area after
text_file_name
holds the S3 key normally.