Skip to content

Commit

Permalink
added license and contributing
Browse files Browse the repository at this point in the history
updated readme
  • Loading branch information
Martin Kluska committed Jan 17, 2017
1 parent a249add commit 512eb08
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 34 deletions.
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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.

## 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).

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

- **Document any change in behaviour.** Make sure the `README.md` and any other relevant
documentation are kept up-to-date.

- **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.

**Thank you!**

# Handler class
The basic handler `AbstractHandler` allows to implement own detection of the chunk mode and file naming. Stored in the Handler namespace but you can
store your handler at any namespace (you need to pass the class to the `FileReceiver` as a parameter)

### You must implement:

- `getChunkFileName()` - Returns the chunk file name for a storing the tmp file
- `isFirstChunk()` - Checks if the request has first chunk
- `isLastChunk()` - Checks if the current request has the last chunk
- `isChunkedUpload()` - Checks if the current request is chunked upload
- `getPercentageDone()` - Calculates the current uploaded percentage

### Automatic detection
To enable your own detection, just overide the `canBeUsedForRequest` method

```php
public static function canBeUsedForRequest(Request $request)
{
return true;
}
```

# Fork
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
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License (MIT)

Copyright (c) 2016 Martin Kluska <martin@kluska.cz>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
48 changes: 14 additions & 34 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ Easy to use service for chunked upload with several js providers on top of Larav
* [Route](#route)
* [Providers/Handlers](#providers-handlers)
* [Changelog](#changelog)
* [Contribution](#contribution)
* [Contribution or overriding](#contribution-or-overriding)
* [Suggested frontend libs](#suggested-frontend-libs)

## Instalation
## Installation

**Install via composer**

Expand Down Expand Up @@ -247,7 +248,7 @@ When using uploader for the cross domain request you must setup the `chunk.name.
Then setup your laravel [Setup guide](https://github.com/barryvdh/laravel-cors)

## Providers/Handlers
Use `AbstractHandler` for type hint or use a specific handler to se aditional methods.
Use `AbstractHandler` for type hint or use a specific handler to se additional methods.

### ContentRangeUploadHandler

Expand Down Expand Up @@ -313,40 +314,19 @@ The cloud drive is not supported becouse of the chunked write (probably could be
- [ ] add an example project
- [ ] add support to different drive than a local drive

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

### Handler class
The basic handler `AbstractHandler` allows to implement own detection of the chunk mode and file naming. Stored in the Handler namespace but you can
store your handler at any namespace (you need to pass the class to the `FileReceiver` as a parameter)

#### You must implement:

- `getChunkFileName()` - Returns the chunk file name for a storing the tmp file
- `isFirstChunk()` - Checks if the request has first chunk
- `isLastChunk()` - Checks if the current request has the last chunk
- `isChunkedUpload()` - Checks if the current request is chunked upload
- `getPercentageDone()` - Calculates the current uploaded percentage

#### Automatic detection
To enable your own detection, just overide the `canBeUsedForRequest` method

```php
public static function canBeUsedForRequest(Request $request)
{
return true;
}
```

##### Fork
Edit the `HandlerFactory` and add your handler to the `$handlers` array

##### At runtime or without forking
Call the `HandlerFactory::register()` to register your own Handler
## Contribution or overriding
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute changes. All contributions are welcome.

# Suggested frontend libs

* https://github.com/lemonCMS/react-plupload
* https://github.com/moxiecode/plupload
* https://github.com/blueimp/jQuery-File-Upload

## 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 Martin Kluska

0 comments on commit 512eb08

Please sign in to comment.