I am trying to move file between a folder using boto3 , and using boto3 for this , example is here
s3_resource = boto3.resource('s3')
# Copy object A as object B
s3_resource.Object('dev-files', 'your-folder/my.txt').copy_from(
CopySource='my-folder/my.txt')
# Delete the former object A
s3_resource.Object('dev-files', 'my-folder/my.txt').delete()
and getting this error :(
An error occurred (NoSuchBucket) when calling the CopyObject operation: The specified bucket does not exist
CodePudding user response:
The CopySource
parameter is defined as:
The string form is {bucket}/{key} or {bucket}/{key}?versionId={versionId} if you want to copy a specific version. You can also provide this value as a dictionary. The dictionary format is recommended over the string format because it is more explicit. The dictionary format is: {'Bucket': 'bucket', 'Key': 'key', 'VersionId': 'id'}. Note that the VersionId key is optional and may be omitted.
Therefore this line:
CopySource='my-folder/my.txt')
should include the bucket name at the start:
CopySource='dev-files/my-folder/my.txt')