What is the Difference between file_upload() and put_object() when uploading files to S3 using boto3

Tushar Niras picture Tushar Niras · May 2, 2017 · Viewed 8.1k times · Source

I'm using boto3 and trying to upload files. It will be helpful if anyone will explain exact difference between file_upload() and put_object() s3 bucket methods in boto3 ?

  • Is there any performance difference?
  • Does anyone among these handles multipart upload feature in behind the scenes?
  • What are the best use cases for both?

Answer

garnaat picture garnaat · May 2, 2017

The upload_file method is handled by the S3 Transfer Manager, this means that it will automatically handle multipart uploads behind the scenes for you, if necessary.

The put_object method maps directly to the low-level S3 API request. It does not handle multipart uploads for you. It will attempt to send the entire body in one request.