A lightweight, extensible library for processing content ranges and partial resource requests in PHP
composer require daverandom/resume
See examples directory
- Write more tests
- Write more examples
- Write proper docs
- Maintain until one of us dies
A lightweight, extensible library for processing content ranges and partial resource requests in PHP
License: MIT License
Thank you so much for all the work you put into this library. However, I can't find the code that actually returns the file to the user, and I can't understand the example code that calls the library. I wanted to write my own simpler function, using your library to learn from, but I don't have the patience to read through all the code to understand it. I apologize for my lack of patience, but I'll look elsewhere to try to understand this "range" business. I've written a function that sends the file in chunks, but it doesn't allow the user to reposition the video and it only works on Firefox, not on Chrome, due to lack of "range".
Editorial: it is strange that some everyday operations, like doing insecure FTP, is easy to do based on just the PHP Manual, yet other operations, like doing secure FTP or providing the user with a video file, are hairy and not explained in the Manual.
Hi Chris Wright,
I came here from your StackOverflow post, which mentions that your code runs on PHP 5.4 or later:
https://stackoverflow.com/questions/157318/resumable-downloads-when-using-php-to-send-the-file/4451376#4451376
However, the composer.json in this repository requires PHP 7.1 or later. I'm unfortunately stuck at PHP 7.0 at the moment, and I was wondering:
Thank you in advance,
Koen
It would be good if we could set a custom filename rather than relying on the filename of the file being served. In my case, the file to be served has a filename of random characters but I'd like to serve the file with a "friendly" name.
Looking at the code and examples and I can't see how I could set additional headers for cache control. It's not possible to extend the Servlet class and overwrite the default headers method as the class is final.
I'm using your class to resume an audio stream. When I close the stream, cancelling the running download, I get the following error:
PHP Fatal error: Uncaught TypeError: fclose() expects parameter 1 to be resource, int given in [....]vendor/daverandom/resume/src/FileResource.php:114
I'm running PHP 7.4.16. Did I implement your class wrong or is this something that shouldn't happen?
Thanks for your amazing work on this!
Hi!
As far as i can see, the full filesize is always returned as Content-length. I think this is not completely compliant with the definition of 206 Partial Content (rfc7233). or am i wrong?
HTTP/1.1 206 Partial Content
Date: Thu, 05 Apr 2018 21:26:15 GMT
Server: Apache/2.4.27 (Win64) OpenSSL/1.1.0f PHP/7.1.9
X-Powered-By: PHP/7.1.9
Content-Length: 1000 // currently in each response constant
accept-ranges: bytes
Content-Range: bytes 445-999/1000
Content-Type: video/x-matroska
... followed by 555 bytes of partial data ...
shouldn't it be in this example:
Content-Length: 555
Which means it has to be calculated individually for each response and range?
Hi I am using this beautiful library and i though that this is just awesome but it would be better it this supports 5.4 as a minimum requirement.
Currently i ll be using php version to determine weather i ll use this or other classes for pp versions.
Thanks
Thank you for this useful library, which I haven't tried yet.
Don't understand the example code require __DIR__ . '/../vendor/autoload.php';
. What is this autoload.php? Is it necessary? What does it do? Where is this code? Where is it called? Who is the 'vendor'? Where is it documented? Why no comment in the example code?
It appears there is no option to pass a variable filename to the getAdditionalHeaders()
function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.