Downloading file to private server

Hi,

Im trying to download the stl file directly to our private server, but when I paste the link to my php script, the file does not work. I make it work only if I download the file to PC, add .zip extension, unzip it and add .stl extension.
It is quite a strange behaviour because if I download the file directly, Im getting a normal .stl working file.

I use :

api.exports.requestAsync({name: “InsoleExportDownload”}).then(
function(response){

           link = response.data.content[0].href;
           window.location=link; // this works
          }
        );

I paste the link to my php script that should download the file to our server using

file_put_contents(“userfiles/” . “44” . “/” . “test_download” . “.stl” , file_get_contents($link));
// this will download the file but to make it work, I have to add .zip, then extract and add .stl

The main issues seems download the file from your link to our private server, because if I download a stl file from another link to our server, the file works, but the issue seems the link from your server.

Did you had some previous experience with?

Boris

Hi @bodibodileg, the ShapeDiver backend stores most exported files using gzip encoding, whenever it makes sense depending on the file type (as an example, it does not gzip images). When you download an exported file which is gzip encoded, the backend adds a Content-Encoding: gzip header such that the browser will uncompress the file. However our backend doesn’t care about the Accept-Encoding header sent by the client, it always assumes the client will look at the Content-Encoding and be able to decompress gzip. This is not handled automatically by PHP’s file_get_contents, but as you already figured out this can easily be done using PHP: