Welcome Guest, Not a member yet? Register   Sign In
Is there a way to upload files directly to AWS without saving it first in writeable
#1

I am using CI4 file/image upload with AWS PHP SDK and it is working fine, but the way I use it is the file is saved in writeable folder directory first then moved to AWS S3,then the file in writeable is deleted. This is good for a few hundred or thousand users but our company has estimated our website to have around 10,000 concurrent users many of which may upload a file every now and then. I think this might put a huge load on the server hosting our site if enough users uploaded images and it goes to the writeable folder even though it is deleted afterwards. My Question is, is there a way to directly upload the file to AWS S3 and not save it in writeable folder? Thanks a lot.
Reply
#2

In any case, the file is saved when uploading to a temporary directory.
The move() and store() methods simply move it to another directory.
You can skip the move step and work directly with the temporary file to save to AWS.
Reply
#3

I concur!
Reply
#4

(07-13-2022, 08:53 PM)iRedds Wrote: In any case, the file is saved when uploading to a temporary directory.
The move() and store() methods simply move it to another directory.
You can skip the move step and work directly with the temporary file to save to AWS.
Thanks, can you point out to me how this can be achieved? I am using the AWS PHP SDK, and it requires a filepath from the file on my server for it to move the file to AWS S3. I could not find any resource that would let me skip the move process because it is the process that places the file in the temporary folder (writable folder) in the first place.
Reply
#5

You must skip the move process but you need to implement the upload to S3. In alternative you can use presigned requests to upload to S3 directly:

Code:
https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-url.html
https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-post.html
Reply




Theme © iAndrew 2016 - Forum software by © MyBB