1. Go to this page and download the library: Download anton-am/do-spaces-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Don't start any path with a forward slash, or it will give "SignatureDoesNotMatch" exception
$path_to_file = "image.png";
$space->UploadFile($path_to_file, "public");
$download_file = "image.png";
$save_as = "folder/downloaded-image.png";
$space->DownloadFile($download_file, $save_as);
//List all files and folders
$files = $space->ListObjects();
//Check if a file/folder by that name already exists. True/False.
$space->DoesObjectExist($file_name);
//Pull information about a single object.
$file_info = $space->GetObject($file_name);
//Upload a complete directory instead of a single file.
$space->UploadDirectory($path_to_directory, $key_prefix);
//Pull Access Control List information.
$acl = $space-ListObjectACL($file_name);
//Update Access Control List information.
$space->PutObjectACL($file_name, $acl_info_array);
//List all Spaces available in account.
$spaces = $space->ListSpaces();
//Delete a Space.
$space->DestroyThisSpace();
//Download whole Space to a folder.
$space->DownloadSpaceToDirectory($directory_to_download_to);
//Get the name of the current Space.
$space_name = $space->GetSpaceName();
//Pull the CORS policy of the Space.
$cors = $space->ListCORS();
//Update the CORS policy of the Space.
$space->PutCORS($new_policy);
//Pull the Access Control List information of the Space.
$acl = $space->ListSpaceACL();
//Update the Access Control List information of the Space.
$space->PutSpaceACL($new_acl);