File download - cannot open pdf file: permission deniedHow do I download a binary file over HTTP?Proper MIME media type for PDF filesMerge / convert multiple PDF files into one PDFInserting a pdf file in latexASP.NET MVC: How can I get the browser to open and display a PDF instead of displaying a download prompt?Cannot open dynamic PDF files in Internet ExplorerHow can I set a policy for an s3 bucket that allows authenticated users to list the bucket or get any file from the bucketAmazon S3 file 'Access Denied' exception in Cross-AccountLimitations on opening pdf file in AndroidOpening a tab with a PDF attachment in a WebviewLaravel- Unable to export to PDF because a binary supposedly has permission denied?

How much maintenance time did it take to make an F4U Corsair ready for another flight?

How does proof assistant organize knowledge?

Is 悪いところを見つかった proper Japanese?

Does Molecular Weight of a Gas affect its lifting properties at the same velocity over the same wing?

How would timezones work on a planet 100 times the size of our Earth

Safest way to store environment variable value in a file

Email address etiquette - Which address should I use to contact professors?

A Non Math Puzzle. What is the middle number?

These were just lying around

What is my malfunctioning AI harvesting from humans?

If clocks themselves are based on light signals, wouldn't we expect the measured speed of light to always be the same constant?

How can I decide if my homebrew item should require attunement?

Generate Brainfuck for the numbers 1–255

Is it feasible to get a hash collision for CRC32, MD-5 and SHA-1 on one file?

How can Radagast come across Gandalf and Thorin's company?

How to assign many blockers at the same time?

How are you supposed to know the strumming pattern for a song from the "chord sheet music"?

How do some PhD students get 10+ papers? Is that what I need for landing good faculty position?

Is this n-speak?

Random Double Arc Endpoint Angles

Bitcoin successfully deducted on sender wallet but did not reach receiver wallet

How can God warn people of the upcoming rapture without disrupting society?

Heating Margarine in Pan = loss of calories?

0xF1 opcode-prefix on i80286



File download - cannot open pdf file: permission denied


How do I download a binary file over HTTP?Proper MIME media type for PDF filesMerge / convert multiple PDF files into one PDFInserting a pdf file in latexASP.NET MVC: How can I get the browser to open and display a PDF instead of displaying a download prompt?Cannot open dynamic PDF files in Internet ExplorerHow can I set a policy for an s3 bucket that allows authenticated users to list the bucket or get any file from the bucketAmazon S3 file 'Access Denied' exception in Cross-AccountLimitations on opening pdf file in AndroidOpening a tab with a PDF attachment in a WebviewLaravel- Unable to export to PDF because a binary supposedly has permission denied?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















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










share|improve this question
























  • Are the files on S3 public (yes: just use the link and let them download; no: use send_data to access and send)? Are you uploading them there with ActiveStorage to begin with?

    – oneWorkingHeadphone
    Mar 27 at 10:58











  • No, they are not. And I don't want to use send_data since I try to avoid streaming

    – Dende
    Mar 27 at 11:16











  • If you compare the file sizes between what you can pull from the command line and what's saved with your download_pdf function, are they the same?

    – oneWorkingHeadphone
    Mar 27 at 13:07

















0















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










share|improve this question
























  • Are the files on S3 public (yes: just use the link and let them download; no: use send_data to access and send)? Are you uploading them there with ActiveStorage to begin with?

    – oneWorkingHeadphone
    Mar 27 at 10:58











  • No, they are not. And I don't want to use send_data since I try to avoid streaming

    – Dende
    Mar 27 at 11:16











  • If you compare the file sizes between what you can pull from the command line and what's saved with your download_pdf function, are they the same?

    – oneWorkingHeadphone
    Mar 27 at 13:07













0












0








0








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










share|improve this question














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







ruby-on-rails pdf amazon-s3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 9:22









DendeDende

1482 silver badges11 bronze badges




1482 silver badges11 bronze badges















  • Are the files on S3 public (yes: just use the link and let them download; no: use send_data to access and send)? Are you uploading them there with ActiveStorage to begin with?

    – oneWorkingHeadphone
    Mar 27 at 10:58











  • No, they are not. And I don't want to use send_data since I try to avoid streaming

    – Dende
    Mar 27 at 11:16











  • If you compare the file sizes between what you can pull from the command line and what's saved with your download_pdf function, are they the same?

    – oneWorkingHeadphone
    Mar 27 at 13:07

















  • Are the files on S3 public (yes: just use the link and let them download; no: use send_data to access and send)? Are you uploading them there with ActiveStorage to begin with?

    – oneWorkingHeadphone
    Mar 27 at 10:58











  • No, they are not. And I don't want to use send_data since I try to avoid streaming

    – Dende
    Mar 27 at 11:16











  • If you compare the file sizes between what you can pull from the command line and what's saved with your download_pdf function, are they the same?

    – oneWorkingHeadphone
    Mar 27 at 13:07
















Are the files on S3 public (yes: just use the link and let them download; no: use send_data to access and send)? Are you uploading them there with ActiveStorage to begin with?

– oneWorkingHeadphone
Mar 27 at 10:58





Are the files on S3 public (yes: just use the link and let them download; no: use send_data to access and send)? Are you uploading them there with ActiveStorage to begin with?

– oneWorkingHeadphone
Mar 27 at 10:58













No, they are not. And I don't want to use send_data since I try to avoid streaming

– Dende
Mar 27 at 11:16





No, they are not. And I don't want to use send_data since I try to avoid streaming

– Dende
Mar 27 at 11:16













If you compare the file sizes between what you can pull from the command line and what's saved with your download_pdf function, are they the same?

– oneWorkingHeadphone
Mar 27 at 13:07





If you compare the file sizes between what you can pull from the command line and what's saved with your download_pdf function, are they the same?

– oneWorkingHeadphone
Mar 27 at 13:07












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55373643%2ffile-download-cannot-open-pdf-file-permission-denied%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55373643%2ffile-download-cannot-open-pdf-file-permission-denied%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript