Skip to content

Commit

Permalink
feat: add dreamobjects storage
Browse files Browse the repository at this point in the history
  • Loading branch information
aloks98 committed Oct 28, 2022
1 parent 2a1a4d2 commit 4069fdc
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/Storage/Device/DreamObjects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Utopia\Storage\Device;

use Utopia\Storage\Device\S3;

class DreamObjects extends S3
{
/**
* Regions constants
*
*/
const US_EAST_1='us-east-1';

/**
* Object Storage Constructor
*
* @param string $root
* @param string $accessKey
* @param string $secretKey
* @param string $bucket
* @param string $region
* @param string $acl
*/
public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::US_EAST_1, string $acl = self::ACL_PRIVATE)
{
parent::__construct($root, $accessKey, $secretKey, $bucket, $region, $acl);
$this->headers['host'] = $bucket.'objects-'.$region.'.'.'dream.io';
}

/**
* @return string
*/
public function getName(): string
{
return 'DreamHost Object Storage';
}

/**
* @return string
*/
public function getDescription(): string
{
return 'DreamHost Object Storage';
}
}
1 change: 1 addition & 0 deletions src/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Storage
const DEVICE_WASABI = 'Wasabi';
const DEVICE_BACKBLAZE = 'Backblaze';
const DEVICE_LINODE= 'Linode';
const DEVICE_DREAMOBJECTS = 'DreamObjects';

/**
* Devices.
Expand Down
30 changes: 30 additions & 0 deletions tests/Storage/Device/DreamObjectsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Utopia\Tests;

use Utopia\Storage\Device\DreamObjects;
use Utopia\Tests\S3Base;

class DreamObjectsTest extends S3Base
{
protected function init(): void
{
$this->root = '/root';
$key = $_SERVER['DREAMOBJECTS_ACCESS_KEY'] ?? '';
$secret = $_SERVER['DREAMOBJECTS_SECRET'] ?? '';
$bucket = "utopia-dreamobjects-store";

$this->object = new DreamObjects($this->root, $key, $secret, $bucket, DreamObjects::US_EAST_1, DreamObjects::ACL_PUBLIC_READ);

}

protected function getAdapterName(): string
{
return 'DreamHost Object Storage';
}

protected function getAdapterDescription(): string
{
return 'DreamHost Object Storage';
}
}

0 comments on commit 4069fdc

Please sign in to comment.