Skip to content

Commit

Permalink
Merge branch 'pionl-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
zlobato committed Nov 16, 2021
2 parents 6fd5486 + 27da831 commit fa00bc8
Show file tree
Hide file tree
Showing 42 changed files with 942 additions and 484 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tests
travis.yml
.php_cs
.phplint.yml
phpunit.xml
CODE_OF_CONDUCT.md
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
composer.phar
/vendor/
composer.lock

/build
.phpunit.result.cache
.php_cs.cache
19 changes: 19 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/config')
->in(__DIR__ . '/tests')
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return PhpCsFixer\Config::create()
->setRules(array(
'@PHP56Migration' => true,
'@Symfony' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'no_superfluous_phpdoc_tags' => false,
))
->setFinder($finder);
7 changes: 7 additions & 0 deletions .phplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
path: ./
jobs: 5
cache: build/phplint.cache
extensions:
- php
exclude:
- vendor
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: php
php:
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
os:
- linux

Expand Down
14 changes: 12 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Contribution or overriding

Are welcome. To add a new provider just add a new Handler (which extends AbstractHandler). Then implement the chunk
upload and progress.

1. Fork the project.
2. Create your bugfix/feature branch and write your (try well-commented) code.
3. Commit your changes (and your tests) and push to your branch.
4. Create a new pull request against this package's `master` branch.
5. **Test your code in [laravel-chunk-upload-example](https://github.com/pionl/laravel-chunk-upload-example)**.

## Pull Requests

- **Use the [PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).**
The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
The easiest way to apply the conventions is to use `composer run lint:fix`.

- **Consider our release cycle.** We try to follow [SemVer v2.0.0](http://semver.org/).

Expand All @@ -20,6 +22,14 @@ upload and progress.
- **Create feature branches.** Don't ask us to pull from your master branch.

- **One pull request per feature.** If you want to do more than one thing, send multiple pull requests.

### Before pull-request do:

1. Rebase your changes on master branch
2. Lint project `composer run lint`
3. Run tests `composer run test`
4. (recommended) Write tests
5. (optinal) Rebase your commits to fewer commits

**Thank you!**

Expand Down Expand Up @@ -49,4 +59,4 @@ public static function canBeUsedForRequest(Request $request)
Edit the `HandlerFactory` and add your handler to the `$handlers` array

# At runtime or without forking
Call the `HandlerFactory::register($name)` to register your own Handler at runtime and use it
Call the `HandlerFactory::register($name)` to register your own Handler at runtime and use it
23 changes: 13 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@
}
],
"scripts": {
"analyze": "./vendor/bin/phpcs",
"analyze-fix": "./vendor/bin/phpcbf"
"lint:fix": "./vendor/bin/php-cs-fixer fix --config=.php_cs --using-cache false",
"lint:check": "./vendor/bin/phplint",
"lint": "composer run-script lint:fix && composer run-script lint:check",
"test": "./vendor/bin/phpunit"
},
"require": {
"illuminate/http": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
"illuminate/console": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
"illuminate/filesystem": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*"
"illuminate/http": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0",
"illuminate/console": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0",
"illuminate/support": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0",
"illuminate/filesystem": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0"
},
"require-dev": {
"laravel/laravel": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
"phpunit/phpunit": "5.7 || 6.0 || 7.0",
"mockery/mockery": "^0.9.9",
"squizlabs/php_codesniffer": "^3.2"
"laravel/laravel": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0",
"phpunit/phpunit": "5.7 | 6.0 | 7.0 | 7.5 | 8.4 | ^8.5 | ^9.3",
"mockery/mockery": "^1.1.0 | ^1.3.0",
"friendsofphp/php-cs-fixer": "^2.16.0",
"overtrue/phplint": "^1.1 | ^2.0"
},
"autoload": {
"psr-4": {
Expand Down
50 changes: 29 additions & 21 deletions config/chunk-upload.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
<?php
return [

/**
return [
/*
* The storage config
*/
"storage" => [
/**
'storage' => [
/*
* Returns the folder name of the chunks. The location is in storage/app/{folder_name}
*/
"chunks" => "chunks",
"disk" => "local"
'chunks' => 'chunks',
'disk' => 'local',
],
"clear" => [
/**
'clear' => [
/*
* How old chunks we should delete
*/
"timestamp" => "-3 HOURS",
"schedule" => [
"enabled" => true,
"cron" => "25 * * * *" // run every hour on the 25th minute
]
'timestamp' => '-3 HOURS',
'schedule' => [
'enabled' => true,
'cron' => '25 * * * *', // run every hour on the 25th minute
],
],
"chunk" => [
'chunk' => [
// setup for the chunk naming setup to ensure same name upload at same time
"name" => [
"use" => [
"session" => false, // should the chunk name use the session id? The uploader must send cookie!,
"browser" => true // instead of session we can use the ip and browser?
]
]
]
'name' => [
'use' => [
'session' => false, // should the chunk name use the session id? The uploader must send cookie!,
'browser' => true, // instead of session we can use the ip and browser?
],
],
],
'handlers' => [
// A list of handlers/providers that will be appended to existing list of handlers
'custom' => [],
// Overrides the list of handlers - use only what you really want
'override' => [
// \Pion\Laravel\ChunkUpload\Handler\DropZoneUploadHandler::class
],
],
];
63 changes: 0 additions & 63 deletions phpcs.xml

This file was deleted.

5 changes: 0 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Application Test Suite">
Expand All @@ -18,9 +17,5 @@
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
<exclude>
<directory>vendor/</directory>
<directory>tests/</directory>
</exclude>
</filter>
</phpunit>
48 changes: 32 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Laravel chunked upload
# Laravel Chunk Upload

[![Total Downloads](https://poser.pugx.org/pion/laravel-chunk-upload/downloads?format=flat)](https://packagist.org/packages/pion/laravel-chunk-upload)
[![Build Status](https://travis-ci.org/pionl/laravel-chunk-upload.svg?branch=master)](https://travis-ci.org/pionl/laravel-chunk-upload)
Expand All @@ -8,8 +8,15 @@

## Introduction

Easy to use service/library for chunked upload with supporting multiple JS libraries on top of Laravel's file upload with low memory footprint in mind. Currently supports **Laravel 5+ (with 5.5 Auto discovery)** with features as [cross domains requests](https://github.com/pionl/laravel-chunk-upload/wiki/cross-domain-requests), automatic clean schedule and easy usage.
> Supports Laravel from 5.2 to 7 (covered by integration tests on all versions).
Easy to use service/library for chunked upload with supporting multiple JS libraries on top of Laravel's file upload with low memory footprint in mind.

Supports feature as [cross domains requests](https://github.com/pionl/laravel-chunk-upload/wiki/cross-domain-requests), automatic clean schedule and easy usage.

Example repository with **integration tests** can be found in [laravel-chunk-upload-example](https://github.com/pionl/laravel-chunk-upload-example).

> Before adding pull requests read CONTRIBUTION.md. Help me fix your bugs by debugging your issues using XDEBUG (and try to do a fix - it will help you become better).
## Installation

Expand All @@ -18,40 +25,33 @@ Easy to use service/library for chunked upload with supporting multiple JS libra
```
composer require pion/laravel-chunk-upload
```

**2. Add the service provider (Laravel 5.4 and below - supports Auto discovery)**

```php
\Pion\Laravel\ChunkUpload\Providers\ChunkUploadServiceProvider::class
```

**3. Publish the config (Laravel 5.2 and above, optional)**
**2. Publish the config (Optional)**

```
php artisan vendor:publish --provider="Pion\Laravel\ChunkUpload\Providers\ChunkUploadServiceProvider"
```


## Usage

Setup is composed in 3 steps:
Setup consists of 3 steps:

1. Integrate your controller that will handle the file upload. [How to](https://github.com/pionl/laravel-chunk-upload/wiki/controller)
2. Setting route for the controller. [How to](https://github.com/pionl/laravel-chunk-upload/wiki/routing)
2. Set a route for the controller. [How to](https://github.com/pionl/laravel-chunk-upload/wiki/routing)
2. Choose your front-end provider below (we support multiple providers in single controller)

| Library | Wiki | single & chunk upload | simultaneous uploads | In [example project](https://github.com/pionl/laravel-chunk-upload-example) | Author |
|---- |----|----|----| ---- | ---- |
| [resumable.js](https://github.com/23/resumable.js) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/jquery-file-upload) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | [@pionl](https://github.com/pionl) |
| [resumable.js](https://github.com/23/resumable.js) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/resumable-js) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | [@pionl](https://github.com/pionl) |
| [DropZone](https://gitlab.com/meno/dropzone/) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/dropzone) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | [@pionl](https://github.com/pionl) |
| [jQuery-File-Upload](https://github.com/blueimp/jQuery-File-Upload) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/blueimp-file-upload) | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_check_mark: | [@pionl](https://github.com/pionl) |
| [jQuery-File-Upload](https://github.com/blueimp/jQuery-File-Upload) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/jquery-file-upload) | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_check_mark: | [@pionl](https://github.com/pionl) |
| [Plupload](https://github.com/moxiecode/plupload) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/plupload) | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: | [@pionl](https://github.com/pionl) |
| [simple uploader](https://github.com/simple-uploader) | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: | [@dyktek](https://github.com/dyktek) |
| [ng-file-upload](https://github.com/danialfarid/ng-file-upload) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/ng-file-upload) | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: | [@L3o-pold](https://github.com/L3o-pold) |

**Simultaneous uploads:** The library must send last chunk as last, otherwise the merging will not work correctly.

**Custom disk:** At this moment I recommend to use the basic storage setup (not linking public folder). It is not tested (Have free time to ensure it is working? PR the changes!).
**Custom disk:** At this moment I recommend using the basic storage setup (not linking public folder). It is not tested (Have free time to ensure it is working? PR the changes!).

For more detailed information (tips) use the [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki) or for working example continue to separate repository with [example](https://github.com/pionl/laravel-chunk-upload-example).

Expand All @@ -60,12 +60,28 @@ For more detailed information (tips) use the [Wiki](https://github.com/pionl/lar
Can be found in [releases](https://github.com/pionl/laravel-chunk-upload/releases).

## Contribution or extending

> Read contribution before your PR (and use example repository to run integration tests).
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute changes. All contributions are welcome.

## Compatibility

* 7.* (last tested on v7.16.1)
* 6.* (last tested on v6.18.20)
* 5.8.* (last tested on v5.8.38)
* 5.7.* (last tested on v5.7.29)
* 5.6.* (last tested on v5.6.40)
* 5.5.* (last tested on v5.5.49)
* 5.4.* (last tested on v5.4.36)
* 5.3.* (last tested on v5.3.31)
* 5.2.* (last tested on v5.2.45)


## Copyright and License

[laravel-chunk-upload](https://github.com/pionl/laravel-chunk-upload)
was written by [Martin Kluska](http://kluska.cz) and is released under the
[MIT License](LICENSE.md).

Copyright (c) 2016-2018 Martin Kluska
Copyright (c) 2016 and beyond Martin Kluska
Loading

0 comments on commit fa00bc8

Please sign in to comment.