We use S3 service to store files. It is very popular and affordable. The way it works is you create a bucket that the website will use to store all the files. Once the bucket is created you can create folder in the bucket to store the files. You can also assign permission and do a bunch more. See the helpful link for S3.

S3 Client Factory

We use the php library amazon provides to assemble s3 client. We need a secret, key, the region the bucket is on, and amazon api version.

S3 Service

The main function is the uploadFile function. This takes in the file we are uploading, the folder path in the bucket and the filename. The environment name will be the first folder in the bucket. So if you are on the dev environment the file will be uploaded to the dev folder.

An example would be the profile picture

 $url = $this->s3Service->uploadFile($user->getImage(), 'profile_pics', md5($user->getId() . '_profile_id'));

In our dev environment example this would be uploaded to the dev/profile_pics/ folder.