I created a script generating me a pdf file on a daily basis. It is then sent to the user's drive using a simple drive.mount('/content/drive') In order to ensure the use of the script, I would like all the pdf files created to be sent to a specific file stored on a specific drive.
Is there a way to specify this path and this drive account after having sent it to the base drive?
I found very few topics going in this direction and not being very clear on the possibility of uploading files to another drive.
If you have any ideas, I'm all ears!
Good day to you all !
I finally found a solution through the PyDrive library.
Here is an example for the curious little ones ;)
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
gfile = drive.CreateFile({'parents': [{'id': 'ID folder'}]})
gfile.SetContentFile("file path")
gfile.Upload()
Once the imports and the creation of the gauth variable have been executed, you will be asked for permissions on your account (don't be surprised)
Hope this helps anyone in need !