locked
Blob PDF files set as iframe in chrome do not open in iframe rather it gets downloaded RRS feed

  • Question

  • Hi,

    We have uploaded 10k files in Azure storage blob via a tool and the content type of each file is octate stream. In our application we are displaying in iframe using the blob url and SAS token, but the files getting downloaded rather than showing in iframe. Even after changing the Content type to aplication/pdf  of the blob file is not solving the issue. The most interesting part is when i manually upload any file to the Azure blob storage the file contents is PDF/Application the file is showing in the iframe.



    Thursday, October 18, 2018 3:27 PM

Answers

  • Hi Arnav,

    I got the issue nearly.

    I have to update the content typr via code not via any client SDK as it writes to client side only i need to chage the properties and post to server and then it will render in chrome correctly.

    I tried the below code but always get an error as "Parameter is incorrect", can you please tell me whats wrong  with the code?

     CloudStorageAccount storageAccount = CloudStorageAccount.Parse("xxxxxxxxxxxxxxxxxxxxxxx");
    
                    // Create the blob client.
                    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    
                    // Retrieve reference to a previously created container.
                    //CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
                    CloudBlobContainer container = blobClient.GetContainerReference("bpglobe");
    
                    CloudBlockBlob blockBlob = container.GetBlockBlobReference(@"23_S_America\01_Present_Day_GDE_Maps\Local_Maps\Colombia_Lanos region_GDEs_1999.pdf");
                    blockBlob.Properties. ContentType = "application/pdf";
                    blockBlob.Properties.CacheControl = "no-cach

    • Marked as answer by QUDIR ANSARI Thursday, November 1, 2018 4:44 PM
    Sunday, October 21, 2018 11:31 PM

All replies

  • Are you opening this in Chrome ? 

    Did you check ?

    If your PDFs are downloading instead of opening automatically in Chrome, Chrome PDF viewer could be turned off. 

    1. On your computer, open Chrome.
    2. At the top right, click More Settings.
    3. At the bottom, click Show advanced settings.
    4. Under “Privacy”, click Content settings.
    5. Under “PDF Documents," check the box next to "Open PDF files in the default PDF viewer application.”
    6. (Uncheck this box if you want PDFs to open automatically when you click them.)

     


    Arnav Sharma | http://arnavsharma.net/ Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Friday, October 19, 2018 1:31 AM
  • Ref https://apemobile.zendesk.com/hc/en-us/articles/115001569212-PDF-files-are-downloading-instead-of-displaying-in-web-browser-or-opening-in-a-new-tab


    Arnav Sharma | http://arnavsharma.net/ Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Friday, October 19, 2018 1:31 AM
  • Hi Arnav,

    Thanks for taking the pain to look into my issue.

    However the checked the chrome setting and its absolutely fine but my issue remains he same. Not only pdf file there are other files as well which are all getting downloaded rather than opening in browser. 

    Friday, October 19, 2018 2:07 PM
  • Hi Arnav,

    I got the issue nearly.

    I have to update the content typr via code not via any client SDK as it writes to client side only i need to chage the properties and post to server and then it will render in chrome correctly.

    I tried the below code but always get an error as "Parameter is incorrect", can you please tell me whats wrong  with the code?

     CloudStorageAccount storageAccount = CloudStorageAccount.Parse("xxxxxxxxxxxxxxxxxxxxxxx");
    
                    // Create the blob client.
                    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    
                    // Retrieve reference to a previously created container.
                    //CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
                    CloudBlobContainer container = blobClient.GetContainerReference("bpglobe");
    
                    CloudBlockBlob blockBlob = container.GetBlockBlobReference(@"23_S_America\01_Present_Day_GDE_Maps\Local_Maps\Colombia_Lanos region_GDEs_1999.pdf");
                    blockBlob.Properties. ContentType = "application/pdf";
                    blockBlob.Properties.CacheControl = "no-cach

    • Marked as answer by QUDIR ANSARI Thursday, November 1, 2018 4:44 PM
    Sunday, October 21, 2018 11:31 PM