This API provides endpoints to upload and download files from Google Drive. The API offers two routes:
Upload Files: http://localhost:8082/upload
Download Files: http://localhost:8082/download
Both endpoints expect a JSON body with an array named files, containing the full names of the files.
Files will be downloaded to the downloaded-files
folder inside google-drive-services
, and only files inside the temp
folder can be uploaded to Google Drive. You can change these paths accordingly in google_drive_functions.js
.
Before you can use this API, you need to configure it by following these steps:
Create a project in the Google Developer Console. Enable the Google Drive API for your project. Create OAuth 2.0 credentials and download the client_secret.json file.
Navigate to the google-drive-services
folder and open google_drive_functions.js
.
Make the following changes:
1- Set the Google Drive Folder ID:
const folderId = 'your_google_drive_folder_id';
2- Set the Path to the Client Secrets File:
const CREDENTIALS_PATH = path.join(__dirname, 'client_secret.json');
git clone https://github.com/yourusername/nodejs-google-drive-api.git
cd nodejs-google-drive-api
npm install
npm run start
Upload Files: Send a POST request to http://localhost:8082/upload
with a JSON body containing the files array.
Download Files: Send a POST request to http://localhost:8082/download
with a JSON body containing the files array.
For both upload and download routes, the JSON body should look like this:
{
"files": ["dummy-file1.txt", "dummy-file2.txt"]
}
To run the tests using Jest, execute the following command:
npm run test