dani3l's avatar

Storage::put without checking if "has" before

Hi guys

I'm using S3 to upload user image files and I saw that I have like 2000 get requests even though I was just stress-testing the system and only uploaded 2000 files without accessing them

In the league filesystem class the "put" function checks before if the file exists using "has" and then doing write/update accordingly - this is not neccesary when using s3 since it'll eventually call the "upload" function on s3 php client library in both cases. so the "has" function redundant and might cost me a lot of money when going to production since the system would handle hundreds of thousands of images per day

I noticed that there is a function called "write" in the league filesystem class (League\Flysystem\Filesystem) - this is the one I should call directly. Is there anyway to do it? should I just use the flysystem direcly?

thanks!

0 likes
1 reply
leandromatos's avatar

You can try put directly in the bucket.

Like that:

Storage::disk('s3')->getDriver()->put($file, $filename, $header);

Please or to participate in this conversation.