iamfredric/spaces

Signs url for uploading files to DigitalOcean spaces

Installs: 27

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:package

0.1.0 2021-03-02 16:28 UTC

This package is auto-updated.

Last update: 2024-03-23 11:38:51 UTC


README

Table of contents

  1. Requirements
  2. What is this
  3. How do I use it?
  4. Laravel integration
  5. Contributing

Requirements

You will need to use php 7.4 or above.

What's this?

This is a simple package for signing urls for uploads to DigitalOcean Spaces and AWS s3.

How do I use it?

composer require iamfredric/spaces
use \Aws\S3\S3Client;
use Iamfredric\Spaces\Spaces;

$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'ENTER_REGION',
    'endpoint' => 'ENTER_ENDPOINT',
    'credentials' => [
        'key'    => 'ENTER_KEY',
        'secret' => 'ENTER_SECRET',
    ],
]);

$spaces = new Spaces($s3, $bucket = 'bucket');

// You would want to return this response
$response = $spaces->sign();

How do I use it with Laravel?

This one ships ready for Laravel.

composer require iamfredric/spaces

The configurations is per default set to filesystems.disks.s3 if you want to use anyother configurations, define this in filesystem.spaces_key. The required params is region, endpoint, key, secret, and bucket

use Illuminate\Http\Request;
use Iamfredric\Spaces\Spaces;

class StorageController
{
    public function sign(Spaces $spaces)
    {
        return response($spaces->sign(), 201);
    }
}