Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit S3 files with python

I am working with python and I need to check and edit the content of some files stored in S3.
I need to check if they have a char o string. In that case, I have to replace this char/string.

For example: I want to replace ; with . in following file File1.txt

This is an example;

After replace

File1.txt

This in an example.

Is there a way to do the replace without downloading the file?

like image 291
vll1990 Avatar asked Mar 20 '26 22:03

vll1990


1 Answers

Objects in Amazon S3 are immutable (they cannot be changed).

I recommend that your code does the following:

  • Download the file from Amazon S3 to local disk
  • Perform edits on the local file
  • Upload the file to Amazon S3 with the same Key (filename)
like image 187
John Rotenstein Avatar answered Mar 22 '26 12:03

John Rotenstein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!