@openworkspace/drive
v0.1.1
Published
Google Drive API client for files, folders, and permissions
Maintainers
Readme
@openworkspace/drive
Google Drive API client for OpenWorkspace -- search, upload, download, folders, permissions.
Part of the OpenWorkspace monorepo.
Install
npm install @openworkspace/drive @openworkspace/coreUsage
import { createHttpClient } from '@openworkspace/core';
import { searchFiles, uploadFile, downloadFile, createFolder, shareFile } from '@openworkspace/drive';
const http = createHttpClient({ auth: { accessToken: 'token' } });
// Search files
const result = await searchFiles(http, 'budget 2025');
if (result.ok) {
for (const file of result.value.files ?? []) {
console.log(file.name, file.mimeType);
}
}
// Upload a file
await uploadFile(http, {
name: 'report.pdf',
mimeType: 'application/pdf',
content: fileBuffer,
});
// Download a file
const data = await downloadFile(http, 'fileId123');
// Create a folder
await createFolder(http, 'Project Assets');
// Share a file
await shareFile(http, 'fileId123', { type: 'user', role: 'reader', emailAddress: '[email protected]' });API
All functions take an HttpClient as the first parameter and return Result<T, E>.
listFiles(http, options)-- List files with querysearchFiles(http, query)-- Search files by namegetFile(http, fileId)-- Get file metadatadeleteFile(http, fileId)-- Delete a filerenameFile(http, fileId, name)-- Rename a filemoveFile(http, fileId, folderId)-- Move a filecopyFile(http, fileId)-- Copy a fileuploadFile(http, options)-- Upload a filedownloadFile(http, fileId)-- Download file contentexportFile(http, fileId, format)-- Export Google Docs/Sheets/SlidescreateFolder(http, name)-- Create a folderlistPermissions(http, fileId)-- List file permissionsshareFile(http, fileId, options)-- Share a fileunshareFile(http, fileId, permissionId)-- Remove sharing
