Download the PHP package andreinocenti/laravel-file-s3-like without Composer
On this page you can find all versions of the php package andreinocenti/laravel-file-s3-like. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andreinocenti/laravel-file-s3-like
More information about andreinocenti/laravel-file-s3-like
Files in andreinocenti/laravel-file-s3-like
Package laravel-file-s3-like
Short Description A package to upload, update, delete, purge a S3 like storage via Laravel
License mit
Informations about the package laravel-file-s3-like
Laravel Package - Files to S3 Like Cloud Storage
This is a Laravel package that handles and make easy the upload, overwrite, delete, cdn purge of files and directories on AWS S3 like cloud storages.
It supports a form uploaded file (UploadedFile) or a base64 file string
Support
At the actual version it support only Digital Ocean SPACES cloud storage.
In the future I will add new cloud storages support or accept pull requests.
Configuration
You should install it via composer:
composer require andreinocenti/laravel-file-s3-like
This package use the Laravel Illuminate\Support\Facades\Storage facade to handle the files.
So you must config the filesystem AWS like disk that you want to use.
Below the optimal config to be used
config/filesystem.php
Usage
You can use the FileS3LikeSpaces facade
Or you can use the FileS3Like Facade, if you do you must set the repository() you want to use.
Methods / Accessors
FileS3Like and its repositories (Eg: FileS3LikeSpaces)
Method | Description |
---|---|
repository(string $repository): self | The repository is the s3 like service that this package support, that you want to use. Eg.: spaces. Check the Support list |
disk(string $disk): self | Sets the filesystem disk that the Storage facade will use to handle the files on the cloud storage |
directory(string $directory): self | The directory in the cloud storage bucket that will be handled. Important: It will concat with the folder configurated in the file filesystem. The folder configuration, is good to have always the same base directory configured, instead of the "directory()" that can change anytime EG.: if folder was configured to be "public", and the directory "images", the final path will be `public/images`. |
upload(UploadedFile|string $file, ?string $filename = null): DiskFile | Upload the file to the storage. If $filename is empty, the name of the file will be aUUID hash. |
save(string $repository): DiskFile | Upload and update the file on the space disk, purge cache and return the file url. If a file with the same name already exists, it will be overwritten and the cache will be purged. If it is a new file, it will only be uploaded. If $filename is empty, the name of the file will be aUUID hash. |
purge(string $filepath): self | Purges a CDN cache of a file. $filename - Inform the file name and path of the file to be purged. |
delete(string $filepath): self | Delete a file from the cloud storage disk |
deleteDirectory(string $filepath): self | Recursively delete a directory from the cloud storage disk |
directories(string $filepath): array | List directories in the directory set |
files(string $filepath): array | List files in the directory set |
DiskFile
DiskFile is a DTO class that is created and delivered when the functions upload or save are called. The class contain accessors that returns some file data.
Method | Description |
---|---|
getFilepath(): string | Return the file, filepath without the url. Eg: "some/path/to/file.jpg". |
getFilename(): string | Return the file name. Eg: "file.jpg". |
getUrl(): string | Returns the full file url. Eg: "https://somedomain.com/some/path/to/file.jpg". |
getExtension(): string | Returns the file extension. Eg: "jpg". |
All versions of laravel-file-s3-like with dependencies
xantios/mimey Version ^2.2
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
league/flysystem-aws-s3-v3 Version ^1.0|^2.0|^3.0