Skip to content

feat: added serverless support for file uploads #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ARYPROGRAMMER
Copy link

This PR attempts to fix #364

Changes

  • Added support for URL-based and binary file uploads in serverless environments
  • Added tests

Try running with:

const fileManager = new GoogleAIFileManager(apiKey);

// URL-based upload (serverless)
await fileManager.uploadFile("https://example.com/file.pdf", {
  mimeType: "application/pdf"
});

// Binary upload (serverless)
const buffer = await fetch("...").then(r => r.arrayBuffer());
await fileManager.uploadFile(buffer, {
  mimeType: "application/pdf",
  name: "document.pdf" // required for binary inputs
});

// Node.js (unchanged)
await fileManager.uploadFile("./local/file.pdf", {
  mimeType: "application/pdf"
});

Testing

  • Added tests for URL-based uploads
  • Added tests for ArrayBuffer/Uint8Array inputs
  • Added tests for error cases
  • Added tests for filename handling

@Annhiluc Annhiluc added type:feature request New feature request/enhancement status:triaged Issue/PR triaged to the corresponding sub-team p3 labels Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3 status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support GoogleAIFileManager.uploadFile in Serverless Environments (Cloudflare Workers, AWS Lambda, etc.)
2 participants