2017 © Pedro Peláez
 

library flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

image

gelatocloud/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

  • Monday, January 5, 2015
  • by Toptunenko
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,612 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 40 Forks
  • 0 Open issues
  • 5 Versions
  • 6 % Grown

The README.md

flow.js php server Build Status Coverage Status

PHP library for handling chunk uploads. Library contains helper methods for: * Testing if uploaded file chunk exists. * Validating file chunk * Creating separate chunks folder * Validating uploaded chunks * Merging all chunks to a single file, (*1)

This library is compatible with HTML5 file upload library: https://github.com/flowjs/flow.js, (*2)

Basic Usage

if (\Flow\Basic::save('./final_file_destination', './chunks_temp_folder')) {
  // file saved successfully and can be accessed at './final_file_destination'
} else {
  // This is not a final chunk or request is invalid, continue to upload.
}

Make sure that ./chunks_temp_folder path exists. All chunks will be save in this temporary folder., (*3)

If you are stuck with this example, please read this issue: How to use the flow-php-server, (*4)

Advanced Usage

$config = new \Flow\Config();
$config->setTempDir('./chunks_temp_folder');
$file = new \Flow\File($config);

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    if ($file->checkChunk()) {
        header("HTTP/1.1 200 Ok");
    } else {
        header("HTTP/1.1 404 Not Found");
        return ;
    }
} else {
  if ($file->validateChunk()) {
      $file->saveChunk();
  } else {
      // error, invalid chunk upload request, retry
      header("HTTP/1.1 400 Bad Request");
      return ;
  }
}
if ($file->validateFile() && $file->save('./final_file_name')) {
    // File upload was completed
} else {
    // This is not a final chunk, continue to upload
}

Delete unfinished files

For this you should setup cron, which would check each chunk upload time. If chunk is uploaded long time ago, then chunk should be deleted., (*5)

Helper method for checking this:, (*6)

\Flow\Uploader::pruneChunks('./chunks_folder');

Cron task can be avoided by using random function execution., (*7)

if (1 == mt_rand(1, 100)) {
    \Flow\Uploader::pruneChunks('./chunks_folder');
}

Contribution

Your participation in development is very welcome!, (*8)

To ensure consistency throughout the source code, keep these rules in mind as you are working: * All features or bug fixes must be tested by one or more specs. * Your code should follow PSR-2 coding style guide, (*9)

The Versions

05/01 2015

dev-master

9999999-dev

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Aidas Klimas

upload flow file upload chunks resumable.js resumable html5 file upload flow.js

14/11 2013

v0.2.1

0.2.1.0

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

  Sources   Download

MIT

The Development Requires

by Aidas Klimas

upload flow file upload chunks resumable.js resumable html5 file upload flow.js

05/11 2013

v0.2.0

0.2.0.0

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

  Sources   Download

MIT

The Development Requires

by Aidas Klimas

upload flow file upload chunks resumable.js resumable html5 file upload flow.js

31/10 2013

v0.1.1

0.1.1.0

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

  Sources   Download

MIT

The Development Requires

by Aidas Klimas

upload flow file upload chunks resumable.js resumable html5 file upload flow.js

04/10 2013

v0.1.0

0.1.0.0

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

  Sources   Download

MIT

The Development Requires

by Aidas Klimas

upload flow file upload chunks resumable.js resumable html5 file upload flow.js