-
-
Notifications
You must be signed in to change notification settings - Fork 243
Description
This ticket was written by Claude, so take with a grain of salt. I ran into this issue using a Laravel Cloud bucket storage.
Summary
When using Prism with the Gemini provider to analyze files stored in cloud storage (S3, R2, etc.), the file upload fails because the underlying implementation uses
file_get_contents() which requires a local filesystem path.
Environment
- Laravel with cloud storage (e.g., Laravel Cloud R2 bucket, S3)
- google-gemini-php/client package (used by Prism for Gemini)
Current Behavior
The Gemini SDK's UploadRequest.php reads files using:
$contents = file_get_contents($this->filename);
This works for local files but fails for cloud-stored files because:
- Storage::path() only returns valid paths for local disks
- Cloud storage has no local filesystem path - files exist only in the bucket
Error
file_get_contents(lawsuits/xxxx/files/yyyy/document.pdf): Failed to open stream: No such file or directory
Expected Behavior
Prism should support file content passed as a string/stream, or accept a PSR-7 stream, so developers can use Storage::get() to retrieve cloud files and pass the
content directly.
Suggested Fix
Allow passing file content directly (as string or stream) in addition to file paths, e.g.:
// Current - path only
$files->upload(filename: '/path/to/file.pdf', mimeType: $mimeType);
// Proposed - also accept content
$files->upload(content: Storage::get('file.pdf'), mimeType: $mimeType, displayName: 'file.pdf');