I need do allow user to download pdf files directly from s3 bucket.
I figured out a method, which works correctly, but I cannot open downloaded files, getting Permission denied
.
If I do it from console, everything is fine, and I can open downloaded pdf files afterwards.
Here's my method
def download_pdf
pdf_url = @file.pdf_url
f = open(pdf_url)
FileUtils.mv(f.path, "#{@file.id}.pdf")
end
What can be wrong? I tried to close TempFile
, as described here, but it didn't help