Download the PHP package district5/slim-psr-upload-handler without Composer
On this page you can find all versions of the php package district5/slim-psr-upload-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download district5/slim-psr-upload-handler
More information about district5/slim-psr-upload-handler
Files in district5/slim-psr-upload-handler
Package slim-psr-upload-handler
Short Description An easy to use, provider based upload handler, for Slim Framework.
License mit
Homepage https://github.com/district-5/php-slim-psr-upload-handler
Informations about the package slim-psr-upload-handler
District5 - Slim Framework PSR Upload Handler
Introduction...
This is a simple upload handler for Slim Framework. It is designed to be used with the PSR interfaces and is compatible with Slim 4.
Providers cover the following: Google Cloud Storage, AWS S3, and local files.
Simply install with:
Supported Providers...
- Local File (Key:
local
)- This provider will save the file to a local directory.
- Configuration:
path
(string) - The directory to save the file to.overwrite
(bool) - Overwrite the file if it already exists.appendRandom
(bool) - Append a random string to the file name.suppressExceptions
(bool) - Ignore errors and return the UploadedDto object regardless. Overrides the globalsuppressExceptions
option.
- Google Cloud Storage (Key:
gcs
)- This provider will save the file to Google Cloud Storage.
- Configuration:
projectId
(string) - The Google Cloud project id.bucket
(string) - Your Google Cloud Storage bucket name.path
(string) - The path within to bucket the file, for example 'uploads' or 'images'. Leave empty (or null) for root.keyFile
(array) - The JSON decoded (ie, array) version of service account key file.overwrite
(bool) - Overwrite the file if it already exists.appendRandom
(bool) - Append a random string to the file name.acl
(string) - The Google Cloud Storage object ACL.suppressExceptions
(bool) - Ignore errors and return the UploadedDto object regardless. Overrides the globalsuppressExceptions
option.
- AWS S3 (Key:
s3
)- This provider will save the file to Amazon S3.
- Configuration:
region
(string) - The region of the bucket.version
(string) - The version of the S3 API to use.bucket
(string) - The name of the bucket.path
(string) - The path within to bucket the file, for example 'uploads' or 'images'. Leave empty (or null) for root.accessKey
(string) - The access key for the bucket.secretKey
(string) - The secret key for the bucket.overwrite
(bool) - Overwrite the file if it already exists.appendRandom
(bool) - Append a random string to the file name.acl
(string) - The ACL for the object (public-read, private, etc.).suppressExceptions
(bool) - Ignore errors and return the UploadedDto object regardless. Overrides the globalsuppressExceptions
option.
Usage...
Likewise, you can also upload from a local file path...
Creating your own provider...
To create your own provider, you need to extend the District5\UploadHandler\Provider\ProviderAbstract
class.
The ProviderAbstract
class provides a lot of the boilerplate code for you.
Ultimately, there are three required methods to implement:
processFileFromUpload
- This method is called when the file is uploaded and is aSlim\Psr7\UploadedFile
object.processFileFromLocal
- This method is called when the file is being uploaded from a local file path.getRequiredConfigKeys
- This method should return an array of required configuration keys.
There are also optional methods to override:
-
getOptionalConfigKeys
- This method should return an array of configuration keys to values that aren't required to be provided, and can default to a value, for example, if you were adding image resize before upload, you could use...Ultimately, those values provided would be the default, unless overridden in the initial configuration for the provider in the
handlers
config array.
To use this provider, you would add it to the handlers
array in the UploadHandler
configuration.
All versions of slim-psr-upload-handler with dependencies
ext-fileinfo Version *
aws/aws-sdk-php Version 3.*
google/cloud-storage Version ^1.39
php-di/slim-bridge Version ^3.0
slim/psr7 Version ^1.6