This project addresses a common issue faced by users of Google Drive: upload errors that occur when using the web interface. When files fail to upload, it can be challenging to identify which files have not been successfully uploaded.
Manually comparing local files with those in Google Drive is not only tedious but also time-consuming. This script automates the process of checking local files against those stored in Google Drive, ensuring that all necessary files are uploaded without manual verification.
Installed python 3.x, git, pip
Go to the Google Cloud Console.
Create a new project.
Search for "Google Drive API" and enable it for your project
In the same project, go to Enabled APIs & services > Credentials.
Follow the guide to create a service account, add role as Owner and fill in target account in Grant users access section.
Then, go to Service Accounts > KEYS and create a new key in JSON format.
Save the JSON file to the project directory as credit.json
Click on Create Credentials and select OAuth client ID.
Follow the guide to create OAuth client ID Credentials, choose an application type as Web Application.
Right-click on the folder, select Share, and enter the email address of your service account, like compare-file-loca-and-drive@compare-file-local-and-drive.iam.gserviceaccount.com.
Set the permissions to Editor.
git clone https://github.com/RaymondRaman/Automated-Google-Drive-File-Synchronization
Open terminal and run follow command
cd Automated-Google-Drive-File-Synchronization
pip install -r requirements.txt
{
"Google_credentials_paths": "/path/to/your/Credentials.json",
"Target_folder_Path": "/path/to/local/folder",
"ignore_files": [
".DS_Store",
".gitignore",
"node_modules",
".git",
"lib",
"__pycache__",
".ipynb_checkpoints",
"bin",
"pip3.12",
"python",
"pip3",
"nbconfig"
],
"upload_failed": {
"status": "False",
"start_process_doc": "extension.js"
}
}
python script.py
After running the script, monitor the terminal output for any messages indicating which files were successfully uploaded. This will help you identify any files that may have encountered issues during the upload process.
Modify ConfigurationUpdate:
- changing upload_failed status to True
- chaning upload_failed start_process_doc to the specific file that encountered issues
Run Upload Script Again: Execute the script again using:
python script.py