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 3085bfc
Show file tree
Hide file tree
Showing 2 changed files with 76 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';
}
}
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 3085bfc

Please sign in to comment.