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.
Asked
Active
Viewed 32 times
0
-
you definitely should probably use boto3 for this. – juanpa.arrivillaga Jul 12 '23 at 18:45
-
Is there a reason why this should be done with boto3 instead of s3fs? – jjbskir Jul 12 '23 at 20:58
-
nevermind, I think you just want `SFFileSystem.copy` – juanpa.arrivillaga Jul 12 '23 at 21:19
1 Answers
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