This Node.js application watches a specific folder on your local system and automatically uploads any new images to a specified folder on your Google Drive account. It uses the chokidar
library to monitor the folder for changes and Google Drive API
for cloud interaction.
-
Folder to Watch: Specify the folder you want the application to watch. This folder will be monitored for new images to upload.
-
Google Drive Folder ID: Create a public google drive folder which has edit access and copy the folder link.
-
Credentials: Obtain and add your own
cred.json
file in the project directory. This file contains OAuth 2.0 credentials to interact with Google Drive. -
Error Logging: Error logging functionality is included to log and display any errors during the upload process.
- Go to the Google Cloud Console.
- Enable the Google Drive API.
- Create a service account and generate a
cred.json
file. - Save the
cred.json
file in your project directory. - Watch the video reference given below to create the
cred.json
file.
-
Manage Folder Permissions:
- Allow anyone can access permission to the google driver folder.
-
IAM and Admin Permissions:
- Go to the IAM and Admin section.
- Add the service account with appropriate permissions to your requested users.
- Watch the video reference to know about the permissions.
For more detailed guidance on permissions and settings, follow the reference video pinned below.
-
Install Node.js: Make sure Node.js is installed on your system.
-
Install Dependencies:
- Navigate to the project directory and run:
npm install
- Navigate to the project directory and run:
-
Run the Application:
- Start the application:
nodemon app
- Start the application:
After execution, the application will start monitoring the specified folder and uploading new files to the cloud.