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
-
configs
returns an array of the parsed configs. header
returns an instance of\Wester\ChunkUpload\Header
Validation Rules
-
extension
-
size
min
max
Language
You can easily change the validation messages the same as Laravel.
Flags
Chunk::RANDOM_FILE_NAME
creates a random file name.Chunk::ORIGINAL_FILE_NAME
preserves the original file name.Chunk::ORIGINAL_FILE_EXTENSION
preserves 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
200
All of the chunks have been uploaded completely.201
The server is waiting for the next chunk to be sent.
-
Errors
The following status codes will interrupt the process.
400
404
415
422
500
501
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
timeout
andnetwork error
.
Client Side
Headers
There are some headers that should be sent to the server.
x-chunk-number
The current chunk number which is being uploaded.x-chunk-total-number
The total number of chunks.x-chunk-size
Maximum size of each chunk. (each chunk must be 4000 bytes and only the last chunk can be less than that)x-file-name
The uploaded file name.x-file-size
The uploaded file size.x-file-identity
Random 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! 😉