Is blocked or not blocked boto3.Bucket.upload_file?

boto3.Bucket.upload_file blocks or does not block?

i.e. if I ran the following

bucket = session.Bucket(bucket_name)
bucket.upload_file(Key=s3_key, Filename=source_path)
os.remove(source_path)

Do I have a race condition, depending on file size? Or should the download be completed before the file is deleted?

+4
source share
4 answers

The current boto3 is upload_fileblocked. As mootmoot said, you should definitely do some error handling to be safe if you delete the file.

+1
source

, upload_file() S3Transfer, , . (API- S3Transfer) .

+1

, , API, . , - (, ).

bucket = session.Bucket(bucket_name)
try :
  bucket.upload_file(Key=s3_key, Filename=source_path)
  os.remove(source_path)
except : 
  raise

S3 .

bucket.upload_file(
     Key=s3_key, 
     Filename=source_path, 
     extra_args={'Metadata': {'source_path': source_path}}
) 

S3 Bucket . PUT , , (, ).

+1
+1
source

All Articles