Skip to content

Commit 3085bfc

Browse files
author
aloks98
committed
feat: add dreamobjects storage
1 parent 2a1a4d2 commit 3085bfc

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Utopia\Storage\Device;
4+
5+
use Utopia\Storage\Device\S3;
6+
7+
class DreamObjects extends S3
8+
{
9+
/**
10+
* Regions constants
11+
*
12+
*/
13+
const US_EAST_1='us-east-1';
14+
15+
/**
16+
* Object Storage Constructor
17+
*
18+
* @param string $root
19+
* @param string $accessKey
20+
* @param string $secretKey
21+
* @param string $bucket
22+
* @param string $region
23+
* @param string $acl
24+
*/
25+
public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::US_EAST_1, string $acl = self::ACL_PRIVATE)
26+
{
27+
parent::__construct($root, $accessKey, $secretKey, $bucket, $region, $acl);
28+
$this->headers['host'] = $bucket.'objects-'.$region.'.'.'dream.io';
29+
}
30+
31+
/**
32+
* @return string
33+
*/
34+
public function getName(): string
35+
{
36+
return 'DreamHost Object Storage';
37+
}
38+
39+
/**
40+
* @return string
41+
*/
42+
public function getDescription(): string
43+
{
44+
return 'DreamHost Object Storage';
45+
}
46+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Utopia\Tests;
4+
5+
use Utopia\Storage\Device\DreamObjects;
6+
use Utopia\Tests\S3Base;
7+
8+
class DreamObjectsTest extends S3Base
9+
{
10+
protected function init(): void
11+
{
12+
$this->root = '/root';
13+
$key = $_SERVER['DREAMOBJECTS_ACCESS_KEY'] ?? '';
14+
$secret = $_SERVER['DREAMOBJECTS_SECRET'] ?? '';
15+
$bucket = "utopia-dreamobjects-store";
16+
17+
$this->object = new DreamObjects($this->root, $key, $secret, $bucket, DreamObjects::US_EAST_1, DreamObjects::ACL_PUBLIC_READ);
18+
19+
}
20+
21+
protected function getAdapterName(): string
22+
{
23+
return 'DreamHost Object Storage';
24+
}
25+
26+
protected function getAdapterDescription(): string
27+
{
28+
return 'DreamHost Object Storage';
29+
}
30+
}

0 commit comments

Comments
 (0)