GCP – Python: Is it possible to rename a file without using the os module?

Question:

I’m using the google cloud functions, I need to delete and rename files but using the os module and any module which is similar to it, will cause problems on Google cloud platform. I don’t have the exact error message now, but I now that from a previous experience.

I’m thinking to rewrite the file, because reading/writing files is working. Is there any better option that can be safely used in Google cloud functions?

So basically if you do upload a text file to the google cloud function and then do os.rename("foo.txtr,bar.txt"), you get an error like this one.

Asked By: Lynob

||

Answers:

Try this instruction instead:

shutil.move()
Answered By: Aymen