Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which approach is better? Upload a file from client side or from server side?

I want to upload a file to AWS s3. I use nodejs as a server.

I wanted to know which approach is better. Uploading it from client side or Server Side?

As the file size is large I am worried about the bandwidth to send to server side and process it.

At the same time I am worried about the security issues of the key to process it from client side.

What are the pros and cons of upload a file from client side as well as server side?

like image 641
Kodanda Rama Durgarao Poluri Avatar asked Jan 02 '23 20:01

Kodanda Rama Durgarao Poluri


1 Answers

Client -> Your Server -> S3 Upload Considerations:

  • Security - How will you control who uploads files to your server?
  • Security - How will you control how large of files are uploaded to your server?
  • Cost - Inbound traffic to your server is free. Outbound from your server to S3 will be charged to you.
  • Performance - The type and size of your instance will determine overall upload performance from the user to your server and then from your server to S3.
  • Reliability - Your server(s) will need to be available for the users to upload to your server.
  • Reliability - Your server need reliable code to transfer the files to S3.
  • Complexity - You are in control of and responsible for transferring the files to S3 in the customer's mind. Upload problems to your server will be your fault in the customer's mind.

Client Side Upload Directly to S3 Considerations:

  • Security - You have many options to provide access rights to the users to upload to S3: a) Signed URLs b) Access Keys (horrible idea) c) Cognito to provide temporary Access Keys. Recommendation: use Signed URLs generated on your server and no access keys of any kind handed to the client.

  • Cost - Inbound from the client to S3 is free.

  • Performance - Your server is not the man in the middle in regards to performance. Performance will be limited to the performance of the user's Internet connection. Customers will be less likely (but not always) to blame you for poor upload problems.

  • Reliability - There are lots of well tested libraries available for uploading to S3. Recommendation: invest in a production quality client (web browser) library that handles Internet interruptions and other issues, retries, nice user prompts, background uploads, etc.

  • Complexity - You will still need to write code (or purchase) for both the server and the client side. However, by choosing good quality software you can reduce your headaches.

like image 173
John Hanley Avatar answered Jan 05 '23 16:01

John Hanley