1tomany/data-uri
Parse data URIs, base64 strings, plain text, URLs, or local files into a temporary file via an immutable value object. Auto-detect or override MIME type, set an optional display name, and the temp file is deleted automatically on destruct.
Storage facade and Filesystem contracts but requires lightweight adaptation (e.g., wrapping DataUriInterface in a custom adapter).Filesystem for saving files). Lacks validation (e.g., virus scanning, size limits) or advanced processing (e.g., image resizing).DataUriInterface’s auto-deletion on destruction reduces boilerplate cleanup code, a boon for short-lived files in Laravel’s request lifecycle or queues.symfony/filesystem (v7.2/8.0), which Laravel already uses. No conflicts with Laravel’s core or popular packages (e.g., spatie/laravel-medialibrary).fopen()/stream_get_contents(), enabling memory-efficient handling of large files (critical for Laravel’s file uploads or API responses).Storage::disk()->writeStream(), HttpClient responses, or UploadedFile instances.mime_content_type(). Useful for preserving metadata (e.g., text/markdown vs. text/plain).type parameter.Filesystem contracts (e.g., FilesystemAdapter).try-catch-finally blocks or Laravel’s AfterCommitting events to ensure cleanup.memory_limit) may constrain very large data URIs (e.g., >100MB). Test with Laravel’s max_file_size settings.Guzzle or Laravel’s HttpClient..md as text/plain). Recommendation: Use explicit types where possible.FilesystemAdapter to enable seamless use with Laravel’s Storage facade?
Storage::put('temp-file', (new DataUriAdapter())->write($dataUri));UploadedFile for upload handling?Filesystem::put() for large files (>50MB)?symfony/mime be added for more robust MIME type detection (e.g., Fileinfo integration)?ValidationException)?HttpClient)?Filesystem or require manual copying?save() method be added to DataUriInterface for convenience?ShouldQueue jobs)? Risk of files disappearing mid-processing.retainUntilProcessed() flag be added to override auto-deletion?file_get_contents() + manual cleanup)?Storage facade but requires adapter wrapping for full integration.HttpClient responses (e.g., remote files) but lacks native validation.data_uri rule). Requires custom rules or middleware.release() method).symfony/filesystem (v7.2/8.0), which Laravel already includes. No additional dependencies needed.fopen(), stream_get_contents(), and mime_content_type(). Ensure these are enabled in php.ini.DataDecoder::decode().FilesystemAdapter to wrap DataUriInterface for use with Storage::disk().class DataUriAdapter implements FilesystemAdapter {
public function write($path, $contents, $options) {
$dataUri = (new DataDecoder())->decode($contents);
return $dataUri->getPath(); // Temporary file path
}
// Implement other FilesystemAdapter methods...
}
UploadedFile for upload handling.data_uri rule using DataDecoder).HttpClient integration).retainUntilProcessed() flag to override auto-deletion for queues.$dataUri = (new DataDecoder())->decode($uri)->retainUntilProcessed();
dispatch(new ProcessDataUriJob($dataUri));
DataUriInterface to a UploadedFile.DataUriInterface::getPath() to load images for processing.data:image/png;base64,...).DataDecoder::decode('https://example.com/file.jpg') for HTTP URLs.Storage facade.symfony/mime).retainUntilProcessed()).How can I help you explore Laravel packages today?