foodticket/laravel-filesystem-cloudflare-images

A Laravel filesystem driver for Cloudflare Images

v0.0.6 2023-10-23 14:34 UTC

This package is auto-updated.

Last update: 2024-05-23 16:32:57 UTC


README

This package provides a filesystem driver for Cloudflare Images.

Requirements

  • PHP >= 8.0
  • Laravel >= 9.0

Installation

To start using the package, you need to install it via Composer:

composer require foodticket/laravel-filesystem-cloudflare-images

Confuguration

Add the following to your config/filesystems.php file:

'cloudflare-images' => [
    'driver' => 'cloudflare-images',
    'account_id' => env('CLOUDFLARE_IMAGES_ACCOUNT_ID'),
    'api_email' => env('CLOUDFLARE_IMAGES_API_EMAIL', env('CLOUDFLARE_API_EMAIL')),
    'api_key' => env('CLOUDFLARE_IMAGES_API_KEY', env('CLOUDFLARE_API_KEY')),
],

Add the following environment variables to your .env file:

CLOUDFLARE_IMAGES_ACCOUNT_ID=<account id>

If you did not have our Laravel-Cloudflare wrapper yet you also need to add the following environment variables to your .env file:

CLOUDFLARE_IMAGES_API_EMAIL=<API email>
CLOUDFLARE_IMAGES_API_KEY=<API key>

Getting started

The Cloudflare Images filesystem driver can be used as you would use another filesystem driver. The documentation for the Laravel filesystem can be found here.

The following example shows how to use the Cloudflare Images filesystem driver to store a file.

use Illuminate\Support\Facades\Storage;

Storage::disk('cloudflare-images')->put('example.png', 'Contents');

Notes

Cloudflare Images doesnot support directories so not all filesystem methods are available. The following methods are supported:

  • fileExists
  • write
  • read
  • delete
  • visibility
  • mimeType
  • lastModified
  • fileSize
  • move
  • copy

The following methods are not supported:

  • directoryExists
  • writeStream
  • readStream
  • deleteDirectory
  • createDirectory
  • listContents

The following methods still need to be implemented:

  • setVisibility

Security Vulnerabilities

If you discover a security vulnerability within this project, please email me via development@foodticket.nl.