Hi On 10/7/23 14:06, Ilija Tovilo wrote:
file. The most common action after a file uploads is arguably to move it to a permanent location using move_uploaded_file(). With a stream
I'm not sure if this is actually the most common action, at least in modern applications. Generally there is some kind of processing pipeline. You might want to strip exif metadata from images, check the file contents with a virus scanner, recompress images to save disk usage and in the end upload it to some cloud storage service (e.g. S3).
the obvious way to achieve the same is stream_copy_to_stream(). However, as the stream already has a file backing (if big enough, at least) this copy is unnecessary. Please correct me if there's something I have missed.
Especially with the "upload to S3" part, folks will generally already work with a stream abstraction, e.g. PSR-7 together with a PSR-18 HTTP client.
Flysystem is probably the most widely used file system abstraction, being included in Laravel, and it also has a "writeStream" functionality:
https://flysystem.thephpleague.com/docs/usage/filesystem-api/
I also would really like to avoid subtle differences between the automatically and manually invoked files. Given that the overwhelming
Yes, that's fair. However there's already some inconsistency, because to my understanding you would need to check for the HTTP method to determine if calling the function is safe or not, no? As an application developer, it would be great if I could safely call this new function also for POST requests.
Best regards Tim Düsterhus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php