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: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ services:
- BACKBLAZE_ACCESS_KEY
- BACKBLAZE_SECRET
- WASABI_ACCESS_KEY
- WASABI_SECRET
- WASABI_SECRET
- CEPH_ACCESS_KEY
- CEPH_SECRET
Comment on lines +24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these prefixed with "CEPH"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes. CEPH is generally what I have been using with ibm cloud storage for a past year. However, I see the problem here. Will make the PR with IBM_CLOUD_OBJECT prefix, inorder to resolve the issue.

58 changes: 58 additions & 0 deletions src/Storage/Device/IBMCloudObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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 Storage';
}

/**
* @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 Storage';

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

namespace Utopia\Tests\Storage\Device;

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

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

$this->object = new IBMCloudObject($this->root, $key, $secret, $bucket, IBMCloudObject::AP_SOUTH_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 'IBM Cloud Object Storage';
}
}