{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "google-drive-upload-file", "type": "registry:item", "description": "Upload a file to Google Drive", "dependencies": [], "files": [ { "path": "steps/google-drive-upload-file.ts", "content": "/**\n * Upload a file to Google Drive\n *\n * @param fileName - Name for the uploaded file\n * @param fileContent - File content as string or buffer\n * @param mimeType - MIME type of the file\n * @param folderId - Optional parent folder ID\n * @returns The uploaded file details with ID and web link\n *\n * @env GOOGLE_DRIVE_API_KEY - Google Drive API key\n */\n\nimport { FatalError } from \"workflow\"\n\ninterface UploadFileOptions {\n fileName: string\n fileContent: string | Buffer\n mimeType: string\n folderId?: string\n}\n\nexport async function googleDriveUploadFile({ fileName, fileContent, mimeType, folderId }: UploadFileOptions) {\n \"use step\"\n\n const apiKey = process.env.GOOGLE_DRIVE_API_KEY\n if (!apiKey) {\n throw new FatalError(\"GOOGLE_DRIVE_API_KEY environment variable is required\")\n }\n\n if (!fileName || !fileContent || !mimeType) {\n throw new FatalError(\"fileName, fileContent, and mimeType are required\")\n }\n\n const metadata = {\n name: fileName,\n ...(folderId && { parents: [folderId] }),\n }\n\n const form = new FormData()\n form.append(\"metadata\", new Blob([JSON.stringify(metadata)], { type: \"application/json\" }))\n form.append(\"file\", new Blob([fileContent], { type: mimeType }))\n\n const response = await fetch(`https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&key=${apiKey}`, {\n method: \"POST\",\n body: form,\n })\n\n if (!response.ok) {\n const error = await response.text()\n throw new Error(`Failed to upload file to Google Drive: ${error}`)\n }\n\n const data = await response.json()\n return {\n id: data.id,\n name: data.name,\n webViewLink: `https://drive.google.com/file/d/${data.id}/view`,\n }\n}\n", "type": "registry:file", "target": "steps/google-drive-upload-file.ts" } ] }