0

Using python s3fs, how do you copy an object from one s3 bucket to another? I have found answers using boto3, but could not find anything when looking through the s3fs docs.

Andrew Gaul
  • 2,296
  • 1
  • 12
  • 19
jjbskir
  • 8,474
  • 9
  • 40
  • 53

1 Answers1

0

Open from one bucket and write to another:

s3 = S3FileSystem(...)

# You'll want to set a block size
# if your files are particularly large
block_size = 2**20

with s3.open('bucket_a/file', 'rb', block_size=block_size) as infile, s3.open('bucket_b/file', 'wb') as outfile:
    for line in infile:
        outfile.write(line)
C.Nivs
  • 12,353
  • 2
  • 19
  • 44