Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sharrpenized's avatar

Transfer uploaded file directly to S3, without double waiting time

My users upload large images and I store them all in Amazon S3 bucket. After the image has uploaded to bucket, I present user with hyperlink to the image.

The problem:

  1. User wants to upload 10MB file
  2. It takes 10 seconds to travel from user's computer to my server
  3. After server has received last bit, it starts uploading to S3. Another 10 seconds.
  4. After 20 seconds in total, user is presented with hyperlink.

I think these 20 seconds can be reduced by half, to 12 or so. If PHP were smart enough to start uploading to S3 not after the last bit arrived, but after the first bit arrived from user - don't wait for all file to be uploaded, but start streaming on the fly.

Is this possible?

0 likes
4 replies
flinux's avatar

A "dirty" solution would be to use s3fs to mount the remote S3 bucket and then use Laravel local filesystem storage pointing to the s3fs mounted directory.

StormShadow's avatar

I was thinking of allowing my users to upload to the local server and then create a queued job that uploads to s3 in the background after performing resizing operations on them, then updating the database after it s complete and deleting the local photos from my server. Anyone do this?

1 like
bashy's avatar

Why 10 seconds to upload to S3? Slow server? :D

1 like

Please or to participate in this conversation.