Upload a file to the storage provider
The file to upload
Optional
filename: stringOptional custom filename
Promise with storage URL and metadata
Download a file from the storage provider
The storage URL
Promise with file blob
List files from the storage provider
Optional
options: StorageListOptionsOptional filtering and pagination
Promise with file list
Delete a file from the storage provider
The storage URL
Promise with success status
Get provider-specific configuration
Provider configuration object
Searches for an existing folder by name within a specified parent folder
The exact name of the folder to search for
The ID of the parent folder to search within (defaults to 'root')
Promise that resolves to the folder ID if found, or null
if not found
This method queries the Google Drive API to find a folder with the exact name within the specified parent directory. Only searches for folders (not files) and excludes trashed items.
// Search for a folder in the root directory
const folderId = await googleDriveStorage.findFolder("screenshots");
if (folderId) {
console.log("Found folder:", folderId);
} else {
console.log("Folder not found");
}
// Search for a subfolder within another folder
const subFolderId = await googleDriveStorage.findFolder("roasts", parentFolderId);
Creates a new folder within a specified parent folder
The name for the new folder
The ID of the parent folder where the new folder will be created (defaults to 'root')
Promise that resolves to the ID of the newly created folder
Finds an existing folder by name, or creates it if it doesn't exist
The name of the folder to find or create
The ID of the parent folder to search within or create the folder in (defaults to 'root')
Promise that resolves to the folder ID (either existing or newly created)
This is a convenience method that combines findFolder
and createFolder
.
It first searches for an existing folder with the specified name. If found,
it returns the existing folder's ID. If not found, it creates a new folder
and returns the new folder's ID.
// Ensure a folder exists, creating it if necessary
const folderId = await googleDriveStorage.findOrCreateFolder("screenshots");
console.log("Folder ID:", folderId); // Will be same ID if folder already existed
// Create nested folder structure
const parentId = await googleDriveStorage.findOrCreateFolder("projects");
const childId = await googleDriveStorage.findOrCreateFolder("vana-app", parentId);
Refresh the access token using refresh token
Promise with new access token
Google Drive Storage Provider with folder management capabilities
Remarks
Implements storage interface for Google Drive using OAuth2 authentication. Provides file upload/download operations and advanced folder management including search, creation, and nested folder structures. Requires the
https://www.googleapis.com/auth/drive.file
OAuth scope for full functionality.Example