PHPackages                             bag/digitalocean-spaces-helpers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. bag/digitalocean-spaces-helpers

ActiveLibrary[File &amp; Storage](/categories/file-storage)

bag/digitalocean-spaces-helpers
===============================

Helper classes to interact with DigitalOcean spaces object storage using the AWS S3 SDK.

1.0.4(3y ago)034MITPHPPHP &gt;=7.2

Since Jul 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/pudge330/digitalocean-spaces-helpers)[ Packagist](https://packagist.org/packages/bag/digitalocean-spaces-helpers)[ RSS](/packages/bag-digitalocean-spaces-helpers/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (6)Used By (0)

DigitalOcean Spaces Helpers
===========================

[](#digitalocean-spaces-helpers)

Helper classes to interact with DigitalOcean spaces object storage using the AWS S3 SDK and Symfony HttpClient.

This library provides common functionality in regards to creating, deleting, and listing Spaces and objects. This library will also facilitate uploading and downloading objects.

This library is fairly new and the api for various methods could change in the upcoming future. I will do my best to document all changes and not introduce breaking changes without notice.

Upcoming
--------

[](#upcoming)

- Usage examples.
- Discontinuing use of AWS S3 SDK and implementing fully with http api instead

Classes
-------

[](#classes)

### BAG\\Spaces\\Client

[](#bagspacesclient)

Main client class that can be used to manage spaces and objects.

**Constants**

- ACL\_PUBLIC = 'public-read'
- ACL\_PRIVATE = 'private'

#### `constructor($key, $secret, $region)`

[](#constructorkey-secret-region)

NameTypeOptionalDescription$keystringfalseSpaces api key$secretstringfalseSpaces api secret$regionstringfalseSpaces region, eg. nyc1#### `createSpace($name)`

[](#createspacename)

Create space.

Returns true if space was created, false if it already existed and on failure.

NameTypeOptionalDescription$namestringfalseName of space#### `deleteSpace($name)`

[](#deletespacename)

Delete space.

Returns false if space was deleted, false otherwise.

NameTypeOptionalDescription$namestringtrueName of space#### `listSpaces($names = false)`

[](#listspacesnames--false)

Get list of spaces.

Returns array of available spaces.

NameTypeOptionalDescription$namesbooltrueReturn names only#### `spaceExists($space)`

[](#spaceexistsspace)

Check if space exists.

Returns true if space exists, false otherwise.

NameTypeOptionalDescription$spacestringfalseName of space#### `list($space, $keys = false, $arguments = [])`

[](#listspace-keys--false-arguments--)

Get list of objects.

Returns array of objects, false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keysbooltrueReturn keys only$argumentsarraytrueAdditional api arguments#### `get($space, $key, $arguments = [])`

[](#getspace-key-arguments--)

Get object.

Returns object, null if not found or false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key$argumentsarraytrueAdditional api arguments#### `exists($space, $key)`

[](#existsspace-key)

Check if object exists.

Returns true if object exists, false otherwise.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key#### `getAcl($space, $key)`

[](#getaclspace-key)

Get an objects ACL.

Return string or false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key#### `setAcl($space, $key, $acl)`

[](#setaclspace-key-acl)

Set an objects ACL.

Returns true or false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key$aclstringfalseACL value#### `upload($space, $key, $content, $public = false, $arguments = [])`

[](#uploadspace-key-content-public--false-arguments--)

Upload content.

Return key as string if successful or false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key$contentstring
resource
Psr\\Http\\Message\\StreamInterfacefalseContent to add$publicbooltrueObject is public$argumentsarraytrueAdditional api arguments#### `uploadFile($space, $key, $file, $public = false, $arguments = [])`

[](#uploadfilespace-key-file-public--false-arguments--)

Upload file.

Return key as string if successful or false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key$filestringfalseFile path on disk$publicbooltrueObject is public$argumentsarraytrueAdditional api arguments#### `multipartUploadFile($space, $key, $file, $public = false, $arguments = [])`

[](#multipartuploadfilespace-key-file-public--false-arguments--)

Multipart file upload.

Return key as string if successful or false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key$filestringfalseFile path on disk$publicbooltrueObject is public$argumentsarraytrueAdditional api arguments#### `download($space, $key, $destination)`

[](#downloadspace-key-destination)

Downloads a file locally.

Returns true if file downloaded successfully or false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key$destinationstringfalseFile destination#### `publicUrl($space, $key)`

[](#publicurlspace-key)

Get object public URL.

Returns a URL string.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key#### `presignedDownload($space, $key, $duration = '+5 minutes')`

[](#presigneddownloadspace-key-duration--5-minutes)

Generate a presigned download URL.

Returns presigned download URL as a string.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key$durationstringtrueLength of time URL is valid, eg. '+5 minutes'#### `presignedUpload($space, $key, $duration = '+5 minutes')`

[](#presigneduploadspace-key-duration--5-minutes)

Generate a presigned upload URL.

Returns presigned upload URL as a string.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key$durationstringtrueLength of time URL is valid, eg. '+5 minutes'#### `delete($space, $key)`

[](#deletespace-key)

Delete object.

Returns true on success, false on failure.

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseObject key#### `baseKey($key)`

[](#basekeykey)

Get base key. Similar to PHP dirname().

Returns string.

NameTypeOptionalDescription$keystringfalseObject key#### `verifyRequest(&$request, $key, $default = [])`

[](#verifyrequestrequest-key-default--)

Verify HTTP result has particular property.

NameTypeOptionalDescription&amp;$requestobjectfalseApi result$keystringfalseValue key$defaultmixedtrueDefault value#### `createAuthorizationSignature($arguments)`

[](#createauthorizationsignaturearguments)

Create an authorization signature header.

Returns an array. First item being an array of headers use for api authorization, second item is the headers compiled to a string.

NameTypeOptionalDescription$argumentsarrayfalseArguments required to construct signature#### `getClient()`

[](#getclient)

Get S3Client instance.

Returns S3Client.

#### **static** `createClient($key, $secret, $endpoint)`

[](#static-createclientkey-secret-endpoint)

Create S3Client.

Returns S3Client instance.

NameTypeOptionalDescription$keystringfalseSpaces api key$secretstringfalseSpaces api secret$endpointstringfalseApi endpoint#### **static** `create($key, $secret, $endpoint)`

[](#static-createkey-secret-endpoint)

Create Spaces Client.

Returns Client instance.

NameTypeOptionalDescription$keystringfalseSpaces api key$secretstringfalseSpaces api secret$regionstringfalseSpaces region, eg. nyc1### BAG\\Spaces\\Space

[](#bagspacesspace)

Space class that can be used to manage a single space and its objects.

**Constants**

- ACL\_PUBLIC = 'public-read'
- ACL\_PRIVATE = 'private'

#### `construct($space, $key, $secret, $region, $create = false)`

[](#constructspace-key-secret-region-create--false)

NameTypeOptionalDescription$spacestringfalseName of space$keystringfalseSpaces api key$secretstringfalseSpaces api secret$regionstringfalseSpaces region, eg. nyc1$createstringtrueCreate space if non-existent#### `list($keys = false, $arguments = [])`

[](#listkeys--false-arguments--)

Get list of objects.

Returns array of objects, false on failure.

NameTypeOptionalDescription$keysbooltrueReturn keys only$argumentsarraytrueAdditional api arguments#### `get($key, $arguments = [])`

[](#getkey-arguments--)

Get object.

Returns object, null if not found or false on failure.

NameTypeOptionalDescription$keystringfalseObject key$argumentsarraytrueAdditional api arguments#### `exists($key)`

[](#existskey)

Check if object exists.

Returns true if object exists, false otherwise.

NameTypeOptionalDescription$keystringfalseObject key#### `getAcl($key)`

[](#getaclkey)

Get an objects ACL.

Return string or false on failure.

NameTypeOptionalDescription$keystringfalseObject key#### `setAcl($key, $acl)`

[](#setaclkey-acl)

Set an objects ACL.

Returns true or false on failure.

NameTypeOptionalDescription$keystringfalseObject key$aclstringfalseACL value#### `upload($key, $content, $public = false, $arguments = [])`

[](#uploadkey-content-public--false-arguments--)

Upload content.

Return key as string if successful or false on failure.

NameTypeOptionalDescription$keystringfalseObject key$contentstring
resource
Psr\\Http\\Message\\StreamInterfacefalseContent to add$publicbooltrueObject is public$argumentsarraytrueAdditional api arguments#### `uploadFile($key, $file, $public = false, $arguments = [])`

[](#uploadfilekey-file-public--false-arguments--)

Upload file.

Return key as string if successful or false on failure.

NameTypeOptionalDescription$keystringfalseObject key$filestringfalseFile path on disk$publicbooltrueObject is public$argumentsarraytrueAdditional api arguments#### `multipartUploadFile($key, $file, $public = false, $arguments = [])`

[](#multipartuploadfilekey-file-public--false-arguments--)

Multipart file upload.

Return key as string if successful or false on failure.

NameTypeOptionalDescription$keystringfalseObject key$filestringfalseFile path on disk$publicbooltrueObject is public$argumentsarraytrueAdditional api arguments#### `download($key, $destination)`

[](#downloadkey-destination)

Downloads a file locally.

Returns true if file downloaded successfully or false on failure.

NameTypeOptionalDescription$keystringfalseObject key$destinationstringfalseFile destination#### `publicUrl($key)`

[](#publicurlkey)

Get object public URL.

Returns a URL string.

NameTypeOptionalDescription$keystringfalseObject key#### `presignedDownload($key, $duration = '+5 minutes')`

[](#presigneddownloadkey-duration--5-minutes)

Generate a presigned download URL.

Returns presigned download URL as a string.

NameTypeOptionalDescription$keystringfalseObject key$durationstringtrueLength of time URL is valid, eg. '+5 minutes'#### `presignedUpload($key, $duration = '+5 minutes')`

[](#presigneduploadkey-duration--5-minutes)

Generate a presigned upload URL.

Returns presigned upload URL as a string.

NameTypeOptionalDescription$keystringfalseObject key$durationstringtrueLength of time URL is valid, eg. '+5 minutes'#### `delete($key)`

[](#deletekey)

Delete object.

Returns true on success, false on failure.

NameTypeOptionalDescription$keystringfalseObject key#### `baseKey(string $key)`

[](#basekeystring-key)

Get base key. Similar to PHP dirname().

Returns string.

NameTypeOptionalDescription$keystringfalseObject key#### `getClient()`

[](#getclient-1)

Get Client instance.

Returns Client.

### BAG\\Spaces\\Authorization

[](#bagspacesauthorization)

Class that assists with generating http authorization headers.

#### `construct($key, $secret)`

[](#constructkey-secret)

NameTypeOptionalDescription$keystringfalseSpaces api key$secretstringfalseSpaces api secret#### `create($arguments)`

[](#createarguments)

Create authorization headers and return full set of headers generated.

Returns an array. First item being an array of headers use for api authorization, second item is the headers compiled to a string.

NameTypeOptionalDescription$argumentsarrayfalseRequest arguments

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~57 days

Total

5

Last Release

1211d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9447e6ad188caa043faba1baf3867756e0fc8b1492b59d2a5093471c4e9faefc?d=identicon)[b.garcia0429](/maintainers/b.garcia0429)

---

Top Contributors

[![pudge330](https://avatars.githubusercontent.com/u/15351039?v=4)](https://github.com/pudge330 "pudge330 (49 commits)")

---

Tags

s3awsobjectstoragespacesdigitalocean

### Embed Badge

![Health badge](/badges/bag-digitalocean-spaces-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/bag-digitalocean-spaces-helpers/health.svg)](https://phpackages.com/packages/bag-digitalocean-spaces-helpers)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k38.2M84](/packages/aws-aws-sdk-php-laravel)[kolay/xlsx-stream

Streaming XLSX reader and writer for PHP and Laravel. Constant memory regardless of file size, direct S3 multipart streaming, optional born-indexed random access.

437.9k](/packages/kolay-xlsx-stream)[sproutcms/cms

Enterprise content management and framework

242.5k4](/packages/sproutcms-cms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
