Download the PHP package wester/chunk-upload without Composer
On this page you can find all versions of the php package wester/chunk-upload. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wester/chunk-upload
More information about wester/chunk-upload
Files in wester/chunk-upload
Package chunk-upload
Short Description Handle chunked uploads with local and ftp drivers simply in PHP with advanced validation features and localization.
License MIT
Informations about the package chunk-upload
Wester Chunk Upload Library For PHP
Wester chunk upload is a php library to handle chunked uploads which supports local and ftp file upload out of the box.
You'll feel safe with the built-in file validator.
Table of contents
- Installation
- Basic Usage
- Drivers
- Implement The Driver
- Methods
- Properties
- Validation Rules
- Language
- Flags
- HTTP Response Status Codes
- Client Side
- Headers
- Examples
- Javascript
- Contribution
- Support Us
Installation
Basic Usage
Here's an example of the package.
Drivers
This package supports ftp file upload out of the box.
local and ftp or custom drivers can be used.
-
Implement The Driver
Your custom driver should implement the
\Wester\ChunkUpload\Drivers\Contracts\DriverInterface.
Methods
store()stores the chunk and merges it.validate()validates the chunk.getFilePath()gets the final file path.getProgress()gets the progress percentage (float).isLast()checks if its the last chunk.getFileExtension()gets the file extension.getFileName()gets the file name without extension.getFullFileName()gets the full file name with extension.getTempFilePath()gets the temp file path.getSize()gets the current chunk size.getTotalNumber()gets the total number of chunks.setLanguage([...])sets the language to the provided arrayresponse($status = null)returns an instance of\Wester\ChunkUpload\Response
Properties
-
configsreturns an array of the parsed configs. headerreturns an instance of\Wester\ChunkUpload\Header
Validation Rules
-
extension -
sizemin
max
Language
You can easily change the validation messages the same as Laravel.
Flags
Chunk::RANDOM_FILE_NAMEcreates a random file name.Chunk::ORIGINAL_FILE_NAMEpreserves the original file name.Chunk::ORIGINAL_FILE_EXTENSIONpreserves the original file extension.You can also specify a custom file name and extension.
HTTP Response Status Codes
This package uses the HTTP response status codes to decide what to do next if the request fails or succeeds when uploading.
-
Success
200All of the chunks have been uploaded completely.201The server is waiting for the next chunk to be sent.
-
Errors
The following status codes will interrupt the process.
400404415422500501
Feel free to add more status codes to your client side.
If another status code is returned the chunk must be re-uploaded such as
timeoutandnetwork error.
Client Side
Headers
There are some headers that should be sent to the server.
x-chunk-numberThe current chunk number which is being uploaded.x-chunk-total-numberThe total number of chunks.x-chunk-sizeMaximum size of each chunk. (each chunk must be 4000 bytes and only the last chunk can be less than that)x-file-nameThe uploaded file name.x-file-sizeThe uploaded file size.x-file-identityRandom string for the file which must be 32 characters in length.
An example of the headers.
Examples & Packages
You can find examples in wester-chunk-upload-examples repository.
Javascript
The client side implementation in Javascript.
React Native
The client side implementation in React Native.
Contribution
- If you want to add more implementations in other languages please submit your PR to the wester-chunk-upload-examples repository.
Support Us
Just star the repository, that's it! 😉