Thank you for visiting the Rackspace Community
The The Community is live! Post new content or topics so our teams can assist.

Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.

Display PDFs in Browser

This question is not answered.

We're using Cloud Files to store PDF documents.  Our client wants them to be displayed in their browser instead of having to download them.  We tried embedding them like so:

<object data="url" type="application/pdf" height="400" width="100%">
    alt : <a href="url">Name</a>

This works perfectly when the file is hosted from our server but after it's been uploaded to Cloud Files we get a "Failed to load PDF document" error on Chrome (our most commonly used browser).  Does anyone have a way to get this to work?  We're using the PHP API to generate a temporary URL so the user can view just their documents.

All Replies
  • Hi swarrenzimconet,

    It sounds like there might be a few factors preventing this from working as you expected. Either the Content-Disposition header is not getting set on the object in Cloud Files, or the temporary URL signature may not be correct.

    However, to display PDF's in the browser (without the need to embed them in HTML) you can set the Content-Disposition and Content-Type headers to tell the browser that it is indeed a PDF file and that it should open it in the browser if possible. To do this, you can either manipulate these headers when you upload the file to Cloud Files, or using the API or an SDK afterwards. Additionally, you can use the Control Panel to change these headers on objects as well (Go to Storage->Cloud Files select the Container the object is in and then navigate to the object itself. Click the gear icon next to the object and select 'Edit headers' under the Management heading)

    For this behavior the values you want to set are:

    Content-Type: application/pdf
    Content-Disposition: inline

    Once these are set, you should be able to open the temporary URL link in Chrome and have the PDF load.

    For reference, here is the RFC that describes the Content-Disposition header

     If the issue is due to an invalid temporary URL signature being generated, you should be able to identify this via the Developer Console as the requested resource will return a 401 Unauthorized. Should this be the case, I would recommend double checking your configuration to ensure you have the correct X-Account-Meta-Temp-Url-Key set and that the path is set correctly, etc. See: for more details about temporary URL generation.