Python (boto3)
boto3 is the AWS SDK for Python. Point it at the Zata endpoint, and you can use the normal S3 calls to work with your buckets from Python code.
Before you start
- A bucket. See Create a bucket.
- An access key and secret key from the same region as the bucket. See Access keys.
- Python 3 with boto3:
pip install boto3.
Connection settings
Create the client
Keep your keys out of the code. Put them in environment variables:
Then create the client. For a bucket in Mumbai, use https://bom01.zata.ai.
The two checksum settings are needed on botocore 1.36 and newer: without them, large uploads fail with XAmzContentSHA256Mismatch. On older botocore versions, leave those two lines out.
Upload and list files
upload_file uploads large files in parts by itself.
Download a file
List your buckets
A sub-user’s key gets an empty list here, even for buckets it can use. Use the bucket name directly.
Make a download or upload link
A presigned URL lets someone download or upload one file without keys, until the link expires. ExpiresIn is in seconds.
Anyone can then upload with the upload link, for example with curl:
- If you add a
ContentTypetoParams(for example"ContentType": "text/plain"), the upload must send exactly that header (-H "Content-Type: text/plain"), or Zata answers403. Without aContentTypein the link, send noContent-Typeheader. - A link stops working when it expires, or when the key that signed it is deleted or turned off.
- Anyone who has the link can use it until it expires. Share it only with the intended person.
Troubleshooting
Never use verify=False: Zata’s certificates are valid. For other errors, see Large uploads and Wrong endpoint or region.