Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
env:
DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }}
DO_SECRET: ${{ secrets.DO_SECRET }}
IBM_CLOUD_ACCESS_KEY: ${{ secrets.IBM_CLOUD_ACCESS_KEY }}
IBM_CLOUD_SECRET: ${{ secrets.IBM_CLOUD_SECRET }}
LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }}
LINODE_SECRET: ${{ secrets.LINODE_SECRET }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
Expand Down Expand Up @@ -67,6 +69,8 @@ jobs:
env:
DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }}
DO_SECRET: ${{ secrets.DO_SECRET }}
IBM_CLOUD_ACCESS_KEY: ${{ secrets.IBM_CLOUD_ACCESS_KEY }}
IBM_CLOUD_SECRET: ${{ secrets.IBM_CLOUD_SECRET }}
LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }}
LINODE_SECRET: ${{ secrets.LINODE_SECRET }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
Expand Down
59 changes: 59 additions & 0 deletions src/Storage/Device/IBMCloudObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Utopia\Storage\Device;

use Utopia\Storage\Storage;

class IBMCloudObject extends S3
{
/**
* Regions constants
*/
const EU_CENTRAL_1 = 'eu-central-1';

const US_SOUTHEAST_1 = 'us-southeast-1';

const US_EAST_1 = 'us-east-1';

const AP_SOUTH_1 = 'ap-south-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::EU_CENTRAL_1, string $acl = self::ACL_PRIVATE)
{
parent::__construct($root, $accessKey, $secretKey, $bucket, $region, $acl);
$this->headers['host'] = $bucket.'.'.$region.'.'.'cloud.ibm.com';
}

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

/**
* @return string
*/
public function getDescription(): string
{
return 'IBM Cloud Object';
}

/**
* @return string
*/
public function getType(): string
{
return Storage::DEVICE_IBM_CLOUD_OBJECT;
}
}
2 changes: 2 additions & 0 deletions src/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Storage

const DEVICE_LINODE = 'linode';

const DEVICE_IBM_CLOUD_OBJECT = 'IBM Cloud Object';

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

namespace Utopia\Tests\Storage\Device;

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

class IBMCloudObjectTest extends S3Base
{
protected function init(): void
{
$this->root = '/root';
$key = $_SERVER['IBM_CLOUD_ACCESS_KEY'] ?? '';
$secret = $_SERVER['IBM_CLOUD_SECRET'] ?? '';
$bucket = 'utopia-storage-test';

$this->object = new IBMCloudObject($this->root, $key, $secret, $bucket, IBMCloudObject::US_EAST_1, IBMCloudObject::ACL_PRIVATE);
}

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

protected function getAdapterType(): string
{
return $this->object->getType();
}

protected function getAdapterDescription(): string
{
return Storage::DEVICE_IBM_CLOUD_OBJECT;
}
}