AWS Boto3’s S3 API provides two methods that can be used to upload a file to an S3 bucket. These methods are:
In this article, we will look at the differences between these methods and when to use them.
Table of contents
- Configurable - Since
put_objectmaps to the low-level S3 API, it accepts a lot of different parameters and thus can be configured based on your needs.
- No support for multipart uploads: AWS S3 has a limit of 5 GB for a single upload operation.
put_objectdoesn’t support the ability to upload files larger than 5 GB.
upload_file API is also used to upload a file to an S3 bucket. The API exposed by
upload_file is much simpler as compared to
put_object. The details of the API can be found here.
- Simpler API: easy to use and understand
- Supports multipart uploads: Leverages S3 Transfer Manager and provides support for multipart uploads.
upload_file provide the ability to upload a file to an S3 bucket. You should use:
upload_fileif you want a simple API or you are uploading large files (>5GB) to your S3 bucket.
put_objectif you need additional configurability like setting the
ACLon the uploaded object.