sync-drive

1.0.2 • Public • Published

Application designed to manage files and folders as a google drive service

Install

  npm install sync-drive

Generate json file to access google services Access:

  • https://console.cloud.google.com
  • Create service account
  • keys, add new keys
  • export to json

Example of use

  // if you prefer you can use `require`
  import * as fs from 'fs'
  import * as path from 'path'
  import GoogleDriveService from 'sync-drive';

  const credentials = './CredentialsServiceAccount.json';
  const folderId = 'your_folder_id'

  async function run(){
    const upload = new GoogleDriveService(credentials, folderId)
    
    const file = fs.createReadStream(path.resolve('./files/wall-paper.png'))
    const mimeType = 'image/png'

    const response = await upload.createFileUpload("spaces-wall-paper", file, mimeType)
    console.log(response)

  }

  run()

//TODO: upload of file
// await services.createFileUpload(filename: string, file: string, mimeType: string, folderId: string)
//TODO: delete file by id
// await services.deleteFile(fileId: string)
//TODO: list files
// await services.listFiles()
//TODO: create folder
// await services.createFolder(folderName: string)
Note: You need to allow the user created in Service_Acconunt to be able to read and write within a certain folder in Drive. 
This repository does not allow you to access the files contained in the root of the Drive, only within a folder with valid permissions.


Clebson Santos, 2022

Package Sidebar

Install

npm i sync-drive

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

482 kB

Total Files

8

Last publish

Collaborators

  • clebsonsantos