Skip to content

Prism Gemini provider doesn't support cloud storage (S3/R2) for file uploads #781

@petervandijck

Description

@petervandijck

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');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions