Azure Linux Web App Downloading files directly from URL not working

445 views Asked by At

LATEST: I have heard back from Azure Support and supposedly this behavior has something to do with platform upgrades and Linux file systems...

Suppose I have a Linux Web App serving a website, in that website I have some content (PDF files in this case) stored in a folder called 'temp'.

Now I wish to allow visitors to download the file directly by visiting that URL like so (link is fake, just an example)-

http://test.azurewebsites.net/temp/PdfIWantToDownload

This was working before, but recently I have found this to be broken for some reason, and when visiting the above link, the download does get triggered, but it gets stuck at 1MB and does not finish.

I did move all resources to a new Azure subscription, but am unsure if that can create issues like this.

After adding a PHP download handler, the files can get downloaded via this link -

http://test.azurewebsites.net/temp/download.php?filename=PdfIWantToDownload

What is happening here? Is there some kind of config I need to tweak to allow for direct URL download? Or does Azure forbid this kind of use?

EDIT: The download does get stuck when going to the link directly, interestingly enough, the download fails after sometime (which is expected), then if I resume the download (was using Chrome but doubt browser matter in this case), I get to break the 1MB barrier, and successfully downloads it with no issues.

Azure has proven to be useful in many cases, but in this one, it is rather confusing and I am unable to troubleshoot this whatsoever.

1

There are 1 answers

0
Ryan Hill On

While this issue is being resolved, try using the following workaround:

<?php 
    $handle = fopen("http://www.example.com/", "rb"); 
    if (FALSE === $handle) {
        exit("Failed to open stream to URL"); 
    }

    $contents = ''; 
    while (!feof($handle)) {
        $contents .= fread($handle, 8192); 
    }

    fclose($handle); 
?>

https://www.php.net/manual/en/function.fread.php

EDIT: Check out the follow blog post for additional workarounds.