Package Data | |
---|---|
Maintainer Username: | aprzywara |
Maintainer Contact: | mail@oliverheck.de (Oliver Heck) |
Package Create Date: | 2016-01-20 |
Package Last Update: | 2017-11-29 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:02:13 |
Package Statistics | |
---|---|
Total Downloads: | 9,833 |
Monthly Downloads: | 8 |
Daily Downloads: | 0 |
Total Stars: | 8 |
Total Watchers: | 2 |
Total Forks: | 9 |
Total Open Issues: | 0 |
This is a fork from dilab/resumable.php with changes to make it compatible with the Laravel Framework
It is currently a work in progress and it is currently developed with Laravel versions 5.1 and 5.2 in mind.
To install, use composer:
composer require black-bits/resumable.js-laravel-backend
app/Http/routes.php
<?php
// resumable.js routes
Route::get ('resumable/upload', 'UploadController@resumableUpload');
Route::post('resumable/upload', 'UploadController@resumableUpload');
app/Http/Controllers/UploadController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\File;
use Dilab\Network\SimpleRequest;
use Dilab\Network\SimpleResponse;
use Dilab\Resumable;
class UploadController extends Controller
{
/**
* Handles resumeable uploads via resumable.js
*
* @return Response
*/
public function resumableUpload()
{
$tmpPath = storage_path().'/tmp';
$uploadPath = storage_path().'/uploads';
if(!File::exists($tmpPath)) {
File::makeDirectory($tmpPath, $mode = 0777, true, true);
}
if(!File::exists($uploadPath)) {
File::makeDirectory($uploadPath, $mode = 0777, true, true);
}
$simpleRequest = new SimpleRequest();
$simpleResponse = new SimpleResponse();
$resumable = new Resumable($simpleRequest, $simpleResponse);
$resumable->tempFolder = $tmpPath;
$resumable->uploadFolder = $uploadPath;
$result = $resumable->process();
switch($result) {
case 200:
return response([
'message' => 'OK',
], 200);
break;
case 201:
// mark uploaded file as complete etc
return response([
'message' => 'OK',
], 200);
break;
case 204:
return response([
'message' => 'Chunk not found',
], 204);
break;
default:
return response([
'message' => 'An error occurred',
], 404);
}
}
}
$ ./vendor/bin/phpunit