Download the PHP package sisaacongoma/spaces-api without Composer
On this page you can find all versions of the php package sisaacongoma/spaces-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sisaacongoma/spaces-api
More information about sisaacongoma/spaces-api
Files in sisaacongoma/spaces-api
Package spaces-api
Short Description An API wrapper for DigitalOcean's Spaces object storage designed for easy use
License MIT
Informations about the package spaces-api
Makes using DigitalOcean's Spaces object storage super easy.
- Makes everything super simple.
- Automatically handles multipart & stream uploads for large files.
- Uses Spaces terminology for objects instead of S3.
Example
Create a Space & upload, it's as easy as that.
tl;dr
-
Files
- Uploading a file
- Uploading text
- Uploading an entire folder
- Downloading a file
- Downloading your entire Space
- Copy a Space file
- List all files
- Check if file exists
- Retrieve file info
- Create signed temporary sharing URL
- Retrieve public file URL
- Change a file's privacy
- Delete a file
- Delete an entire folder
-
Spaces
- Create a new Space
- Use an existing Space
- List all Spaces
- Change your Space's privacy
- List your Space's CORS rules
- Change your Space's CORS rules
- Destroy your Space
Installing Spaces-API
There are two ways to install Spaces-API. You can either download the project & put it directly in your code's folder, or you can use Composer.
a) The Manual Method
1) Download Spaces-API & place it in your project. 2) Load it from your code:
b) The Composer Method
1) Make sure you have Composer. 2) Install Spaces-API:
3) Make sure your code has the Composer autoloader:
Setup
You'll need a DigitalOcean account & API keys to use Spaces-API. You should be able to generate a pair of keys from the DigitalOcean Dashboard. In the API page, there should be a section with the title "Spaces access keys". Click "Generate New Key" & follow the steps. That'll give you an access key & a secret key.
We'll be using these keys to initiate a Spaces instance:
Usage
Once you have a Spaces instance, you can do pretty much anything the Spaces API allows.
Here is an example of downloading all your files to a local directory:
Top-Level Spaces Functions
These are all the functions a Spaces instance can perform.
Create a new Space
- The third (Space privacy) argument is optional. Defaults to private.
- Returns a new single Space instance. Same as
$spaces->space("my-new-space")
.
Use an existing Space
List all Spaces
Single Space Functions
These are all the functions a Space instance (From $spaces->space("my-new-space")
) can perform!
Upload a stored file
- The second (Save as) argument is optional. Spaces-API attempts to use the original file path as the path on your Space if no save as path is provided.
- The third argument (File privacy) is optional. It defaults to private.
- Returns available info on the file.
Upload text directly
- The first argument (Content) can be a string, but it can also be a StreamInterface or PHP stream resource.
- The third argument (File privacy) is optional. It defaults to private.
- Returns available info on the file.
Upload a local folder
- You can provide a second argument which can be a folder inside your Space where to upload all the files inside the local folder.
Download a file
Download your Space to a local folder
- You can provide a second argument which can be a folder on your Space. Spaces-API will only download the files inside this folder.
Copy a file inside your Space
- DigitalOcean only allows copying across Spaces in the same region.
- You can supply a fourth argument to set the new file's privacy (public/private).
- Returns info on the new file.
List all files inside your Space
- This function automatically iterates till it gets all files but you can set the second argument to false if you want to handle pagination yourself.
- If you set the second argument to false, you can set the third argument to a ContinuationToken.
- Returns an array of files but if the second argument is set to false, the original object is returned.
Check whether a file exists
Get info on a file
Create a signed URL (Used for sharing private files)
Create an unsigned URL (Used for sharing public files)
Change a file's privacy (Public & Private ACL)
Delete a file
Delete an entire folder
Change your Space's privacy (ACL)
List your Space's CORS rules
- This will throw an error if no CORS rules exist.
Set your Space's CORS rules
Destroy your Space
Also deletes all files inside your Space
All versions of spaces-api with dependencies
aws/aws-sdk-php Version ^3.52
guzzlehttp/guzzle Version ^6.3
mtdowling/jmespath.php Version ^2.4
psr/http-message Version ^1.0