lundi 18 février 2019

PHP Laravel - Download returning ZIP file with additional size

I am using Lumen 5.5.

A user may download a zip file that is stored on S3, the PHP will do the following

  1. Download the file from S3 to localhost.
  2. Send the downloaded file to user.

My function is

public function downloadFile(request $request)
{
    $localpath = S3Manager::download($request->s3Key);
    return response()->download($localpath);
}

The files are being downloaded with additional size and I am not able to unzip it on my Mac with the following error:

Unable to expand file "filename.zip" into "Downloads"
Error 1: Operation not permitted.

That's weird because on the Linux machine (backend) I can unzip it easily. I also checked the Content-Length in the browser, the response returned from the server has the correct length (same as in S3) but the downloaded file size is almost double.

In the frontend I am using js-file-download package

 https://www.npmjs.com/package/js-file-download

I'm not sure what is the problem.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire