boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
9.07k stars 1.87k forks source link

Example for MultipartUpload #4233

Closed daveisfera closed 3 months ago

daveisfera commented 3 months ago

Describe the issue

There doesn't appear to be any documentation for how to use MultipartUpload and it errors out saying that the upload_id doesn't exist when trying to use it.

Here's example code:

from uuid import uuid4

import boto3

s3_resource = boto3.resource("s3")
mpu = resource.MultipartUpload("test_bucket", f"test_mpu.txt", str(uuid4()))
for n in range(4):
    part = mpu.Part(n)
    part.upload(Body=open(f"test_{n}.txt").read())

And here's the error that happens:

NoSuchUpload: An error occurred (NoSuchUpload) when calling the UploadPartCopy operation: The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.

Links

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/multipartupload/index.html

RyanFitzSimmonsAK commented 3 months ago

Hi @daveisfera, thanks for reaching out. You're right that the documentation for the resources page is a bit lacking, but fortunately, it's better documented elsewhere. Here's the client MPU operation, and the S3 customization reference. Both of those should be helpful. Please let me know if you have any other questions.

daveisfera commented 3 months ago

Those are both using Client rather than Resource and isn't that at least partially deprecated?

RyanFitzSimmonsAK commented 3 months ago

Nope! Client is fully supported. Resources aren't deprecated, but they are feature-frozen.

daveisfera commented 3 months ago

Doh! I had it backwards and Resource is the one that's no longer being developed

github-actions[bot] commented 3 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.