This is python script that listen to specific folder, once a new file added , the script will upload the file to google drive and delete the file, and save file link!
- Paste service account credentials file name in service_file here.
- Paste your Google Drive Folder ID here.
- Edit to the path you want to listen here.
- Edit and create the folder that will save the uploaded files here.
- Install all libraries.
- Sign in to Google Cloud Console.
- Enable Google Drive API.
- Create a service account.
- Download account Credentials file and paste it in the same directory with the main File and put the credentials file name in the code.
- Create a Folder in your personal Google Drive and paste the folder's id in the code. Folder id is in the folder's link
https://drive.google.com/drive/folders/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Share the folder with the service account's email and make the role "Edit" to let the service account edit your folder and upload files in it.
- Feel free to search about how to create service account in Youtube.
run this script to create and edit service file
sudo vi /etc/systemd/system/YOUR_SERVICE_NAME.service
then edit and paste following script
[Unit]
Description=Google Drive Uploader
After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 /home/your_username/your_path_to_main.py
[Install]
WantedBy=multi-user.target
run
systemctl enable YOUR_SERVICE_NAME
run
systemctl daemon-reload
to reload services
then
systemctl start YOUR_SERVICE_NAME
to start your service