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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

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 sending a file URL, a form uploaded file (UploadedFile) or a base64 file string.

It supports generating a presigned url.

Support

Currently supports:

Configuration

You should install it via composer:

composer require andreinocenti/laravel-file-s3-like

1. Digital Ocean Spaces

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 in config/filesystem.php:

2. Google Cloud Storage (GCS)

To use GCS, you need to install the required dependencies:

composer require google/cloud-storage spatie/laravel-google-cloud-storage

To see more GCS filesystem configs check: https://github.com/spatie/laravel-google-cloud-storage

For uniform bucket level access use: 'visibility_handler' => \League\Flysystem\GoogleCloudStorage\UniformBucketLevelAccessVisibility::class

Then configure the disk in config/filesystem.php:

Ensure you have your Google Cloud Service Account JSON key file reachable and the path correctly set in GOOGLE_APPLICATION_CREDENTIALS environment variable.

Usage

Digital Ocean Spaces

You can use the FileS3LikeSpaces facade:

Or using the generic FileS3Like facade:

Google Cloud Storage (GCS)

Use the FileS3Like facade with the gcs repository:

Upload from stream

Use uploadStream when you already have an open readable stream and want to avoid loading the full file into memory.

Use saveStream when you want the same semantics as save:

Methods / Accessors

FileS3Like and its repositories (Eg: FileS3LikeSpaces, FileS3LikeGCS)

Method Description
repository(string $repository): self The repository is the storage service you want to use. Supported: spaces, gcs.
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 a UUID hash.
uploadStream(resource $stream, string $filename, ?string $mime = null): DiskFile Upload an already opened readable stream directly to the storage disk. Use this for large files to avoid loading the whole file into memory.
save(string $repository): DiskFile Upload and update the file on the storage disk. For Spaces: Purges the CDN cache. For GCS: Same as upload (GCS requires different API for CDN invalidation). If a file with the same name already exists, it will be overwritten. If $filename is empty, the name of the file will be a UUID hash.
saveStream(resource $stream, string $filename, ?string $mime = null): DiskFile Save an already opened readable stream to the storage disk. For Spaces: uploads and purges CDN cache. For GCS: same behavior as uploadStream.
presignedUrl(string $filepath, ?string $filename = null, int $expiration = 900, string|null $fileType = null, bool $public = false): object Create a presigned URL for direct upload to the path in $filepath (relative to the configured folder). $filename is optional and defaults to a UUID; extension is inferred from $fileType or the filename. $fileType accepts a mime type or extension (eg: image/png, jpg, image/*) and is used to set Content-Type. $public toggles the ACL between private (default) and public-read (Note: GCS presigned URLs handle public access differently, but the flag sets the ACL header if supported). $expiration is in seconds; default is 900 (15 minutes).
purge(string $filepath): self Purges a CDN cache of a file. Spaces: Calls DigitalOcean CDN API. GCS: No-op (use Google Cloud CDN invalidation API separately).
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

Presigned URL usage

Use presignedUrl when you need a temporary URL for clients to upload directly to the bucket.

The returned Fluent object contains the presigned URL and useful metadata:

Send the provided headers with the upload request to ensure the ACL and mime type are applied.

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

PHP Build Version
Package Version
Requires php Version ^8.2
xantios/mimey Version ^2.2
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0
league/flysystem-aws-s3-v3 Version ^1.0|^2.0|^3.0
google/cloud-storage Version ^1.48
spatie/laravel-google-cloud-storage Version ^2.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package andreinocenti/laravel-file-s3-like contains the following files

Loading the files please wait ...