Download the PHP package matecat/simple-s3 without Composer
On this page you can find all versions of the php package matecat/simple-s3. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package simple-s3
Simple S3 Client
Simple S3 Client is a simple wrapper of the official SDK PHP Client.
Basic Usage
To instantiate the Client do the following:
Please note that if you don't provide the credentials array, the Client will try to get values from the following environments variables on your system as the original S3Client:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN
If you instead want to authenticate assuming an IAM Role in another AWS Account do the following:
For further config details please refer to the official documentation:
Configuration for the AWS SDK for PHP Version 3
Methods
Here is the list of Client's public methods:
clearBucket
- clear a bucket from all filescopyFolder
- copy the items from a folder to another onecopyItem
- copy an item from a bucket to another onecopyInBatch
- copy in batch items from a bucket to another onecreateBucketIfItDoesNotExist
. create a bucket if it does not existscreateFolder
. create an empty folder in a bucket if it does not existsdeleteBucket
- delete a bucketdeleteBucketPolicy
- delete the bucket policydeleteFolder
- delete a folderdeleteItem
- delete an itemdownloadItem
- download an itemenableAcceleration
- enable the acceleration mode for a bucketgetBucketLifeCycle
get the bucket lifecycle configurationgetBucketPolicy
get the bucket policygetBucketSize
get the size (in Bytes) of files in a bucketgetItem
- get all informations for an itemgetItemsInABucket
get an array of items in a bucketgetItemsInAVersionedBucket
get an array of items in a versioned bucketgetCurrentItemVersion
- get the latest version of an itemgetPublicItemLink
- get the public link to download the itemhasBucket
- check if a bucket existshasFolder
- check if a folder existshasItem
- check if an item existsisBucketVersioned
- check if bucket has versioned enabledopenItem
- get the content of an itemrestoreItem
- try to restore an item from archivesetBucketLifecycleConfiguration
- set bucket lifecycle configurationsetBucketPolicy
- set the bucket policysetBucketVersioning
- set the bucket versioningtransfer
- transfer content from/to bucketsuploadItem
- upload an item to a bucket from a fileuploadItemFromBody
- upload an item to a bucket from the body content
Naming validation for buckets and objects
Please refer to the official AWS policy:
The Client comes with two validators:
These two classes throws you an if the name provided is not compliant with the AWS rule conventions.
Validators are invoked in Client's , and methods.
Objects name escaping
Please read carefully the object safe naming rules.
Escaping object names is entirely up to you.
You can use the provided class, or inject in Client your own encoder if you prefer, but please note that it MUST implement
interface:
Filename trimming
As the Amazon official documentation reports, the filename max size on S3 is 1024 characters.
But you MUST be aware of filename max size of your operating system.
For example, if you run the application on a Linux system, this limit is 255 bytes, so you cannot download a file with a name which exceeds this value.
S3Client comes with a FilenameTrimmer
helper class, which automatically trims the filenames. Default limit value is 255.
To override this limit, use setFilenameMaxSize
method:
Bucket lifecycle
You can set the basic lifecycle for your bucket with method.
For further details please refer to the bucket lifecycle configuration official API documentation.
Bucket policy
You can set the bucket policy using method. Consider the following example:
You can grab bucket policy and delete it by using respectively and methods.
For further details please refer to the bucket policy official API documentation.
Bucket versioning
You can enable bucket versioning:
And now, when you use method, a
For further details please refer to the bucket versioning official API documentation.
Restoring an item
You can use to send a restore an archived object. You can choose between three retrieval options:
- (lasts 5-12 hours)
- (default, lasts 1-5 minutes)
- (lasts 3-5 hours)
For further details please refer to the official documentation:
Caching
In order speed up data retrieval, you can inject a cache handler. Please note that the cache MUST implement . The client comes with a Redis implementation:
Now method will get the elements directly from cache. Please note that caching works ONLY if you provide a prefix to the method:
If you need to skip the cache you can add an extra parameter called exclude-cache
:
Commands
If you have an application which uses Symfony Console, you have some commands available:
- Transfer files from/to a bucket.
- Clears a bucket.
- Creates a bucket.
- Deletes a bucket.
- Flush all data stored in cache.
- Get the cache statistics.
- Copy the items from a folder to another one.
- Copy an object from a bucket to another one.
- Deletes an object from a bucket.
- Download an object from a bucket.
- Upload an object into a bucket.
You can register the commands in your app, consider this example:
Logging
You can inject your logger to log every Client outcome call. Please note that your logger MUST be PSR-3 compliant:
Support
If you found an issue or had an idea please refer to this section.
Authors
- Mauro Cassani - github
License
This project is licensed under the MIT License - see the LICENSE.md file for details
All versions of simple-s3 with dependencies
predis/predis Version ^2.0
aws/aws-sdk-php Version ^3.322
ext-curl Version ^7.3
ext-fileinfo Version ^7.3
ext-redis Version *
ext-json Version *