Created
June 10, 2022 17:02
-
-
Save conkonig/7ebd5ea70f4a1f1f8480b9a921bcde81 to your computer and use it in GitHub Desktop.
Upload a file to DO Spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__ . '/vendor/autoload.php'; | |
// using composer "sociallydev/spaces-api": "3.5" | |
use \SpacesAPI\Spaces; | |
$spaces = new Spaces('apikey', 'secret'); | |
$space = $spaces->space('bucket'); | |
$filename = 'image.png'; | |
$file = $space->uploadFile($img, $filename); | |
$file->makePublic(); | |
$fileurl = $file->getURL(); | |
echo '<img src="' . $fileurl . '" width="200" height="auto" />'; | |
?> | |
<a href="<?php echo $fileurl; ?>"><?php echo $fileurl; ?></a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment