I am trying to download the data stored amazon s3 bucket using paperclip and aws-sdk gem. Object is publicly accessible.
I am having a method in my controller where I intend do download the data directly.
def method_where_downloading_happens
code for finding url from params
send_file "ModelName.attached_file.url"
end
#Tried both with static and dynamic url.
I am getting following error
NoMethodError: undefined method `send_file for main:Object
However if I use :-
send_file open(ModelName.attached_file.url)
Then a file is downloaded but it’s format is binary i.e. windows can’t identify the file_type.
Please help how do I provide direct download when the person hits the link.
You can try this: