Maton

Google Drive

Access the Google Drive API with managed OAuth authentication. List, search, create, and manage files and folders.

Reference

List Files

GET /google-drive/drive/v3/files?pageSize=10

With query:

GET /google-drive/drive/v3/files?q=name%20contains%20'report'&pageSize=10

Only folders:

GET /google-drive/drive/v3/files?q=mimeType='application/vnd.google-apps.folder'

Files in specific folder:

GET /google-drive/drive/v3/files?q='FOLDER_ID'+in+parents

With fields:

GET /google-drive/drive/v3/files?fields=files(id,name,mimeType,createdTime,modifiedTime,size)
maton google-drive file list -Q "name contains 'budget'"

Get File Metadata

GET /google-drive/drive/v3/files/{fileId}?fields=id,name,mimeType,size,createdTime
maton google-drive file view FILE_ID --fields 'id,name,mimeType,size,createdTime'

Download File Content

GET /google-drive/drive/v3/files/{fileId}?alt=media
maton google-drive file download FILE_ID --output ./report.pdf

Export Google Docs

GET /google-drive/drive/v3/files/{fileId}/export?mimeType=application/pdf
maton google-drive file export FILE_ID --mime-type application/pdf --output ./doc.pdf

Create File (metadata only)

POST /google-drive/drive/v3/files
Content-Type: application/json

{
  "name": "New Document",
  "mimeType": "application/vnd.google-apps.document"
}
maton google-drive file create --name 'New Document' --mime-type application/vnd.google-apps.document

Create Folder

POST /google-drive/drive/v3/files
Content-Type: application/json

{
  "name": "New Folder",
  "mimeType": "application/vnd.google-apps.folder"
}
maton google-drive file create --name 'New Folder' --mime-type application/vnd.google-apps.folder

Update File Metadata

PATCH /google-drive/drive/v3/files/{fileId}
Content-Type: application/json

{
  "name": "Renamed File"
}
maton google-drive file update FILE_ID --name 'Renamed File'

Move File to Folder

PATCH /google-drive/drive/v3/files/{fileId}?addParents=NEW_FOLDER_ID&removeParents=OLD_FOLDER_ID
maton google-drive file update FILE_ID --add-parents NEW_FOLDER_ID --remove-parents OLD_FOLDER_ID

Delete File

DELETE /google-drive/drive/v3/files/{fileId}
maton google-drive file delete FILE_ID

Copy File

POST /google-drive/drive/v3/files/{fileId}/copy
Content-Type: application/json

{
  "name": "Copy of File"
}
maton google-drive file copy FILE_ID --name 'Copy of File'

Resources

On this page