0

I'm having issues uploading files with the size of about 400MB to an external disk in Laravel. On the local disk I have no issues storing the uploaded file but when it needs to be uploaded to the S3 disk I get the following error:

ErrorException: fwrite(): Unable to create temporary file, Check permissions in temporary files directory.

The following code is used (which gives no errors):

$contents = file_get_contents($file);
$local = \Storage::disk('local');
$local->put($desitinationUrl,  $contents);

But when the following happens I get an error

$uploadedfile = \Storage::disk('local')->get($destinationUrl);
$s3 = \Storage::disk('s3');
$s3->put($destinationUrl,  $uploadedfile);

Does anyone know where the issue may be? Thanks in advance!

2
  • Do you have the same problem with small files? It would be very useful to understand if it only occurs past a certain size or if size doesn't matter Commented Aug 21, 2020 at 9:03
  • Small files are no issue, I can upload up to about 250MB via this way, but larger than that I get this problem Commented Aug 21, 2020 at 9:04

1 Answer 1

2

You could try directly writing the stream as you read it:

Storage::disk('s3')
  ->writeStream(
      $destinationUrl, 
      Storage::disk('local')->readStream($destinationUrl)
  );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.