Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Oracle Object Storage adapter #91

Closed
Show file tree
Hide file tree
Changes from 2 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
57 changes: 57 additions & 0 deletions src/Storage/Device/OracleObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Utopia\Storage\Device;

use Exception;
use Utopia\Storage\Device;
use Utopia\Storage\Storage;

class OracleObject extends Device
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably extend the S3 adapter because Oracle Object is an S3-compatible storage provider.

{
/**
* @var string
*/
protected string $root = 'oracle-object';

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't there be region constants?

/**
* OracleObject constructor.
*
* @param string $root
*/
public function __construct(string $root = '')
{
$this->root = $root;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There should definitely be more parameters than this like some sort of key and bucket.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks!
Will solve the mentioned things and push the changes.


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

/**
* @return string
*/
public function getType(): string
{
return Storage::DEVICE_ORACLE_OBJECT;
}

/**
* @return string
*/
public function getDescription(): string
{
return 'Adapter for Oracle Object Storage.';
}

/**
* @return string
*/
public function getRoot(): string
{
return $this->root;
}
}
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_ORACLEOBJECT = 'oracleobject';
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be DEVICE_ORACLE_OBJECT just like DEVICE_DO_SPACES:

Suggested change
const DEVICE_ORACLEOBJECT = 'oracleobject';
const DEVICE_ORACLE_OBJECT = 'oracleobject';


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

use PHPUnit\Framework\TestCase;
use Utopia\Storage\Device\OracleObject;

class OracleObjectTest extends TestCase
{
/**
* @var OracleObject
*/
private $oracleObject;

protected function setUp(): void
{
$this->oracleObject = new OracleObject('oracle-object-root');
}

public function testUploadFileToOracleObjectStorage()
{
// Implement your test for the upload method here
$localFilePath = 'local_file.txt';
$remoteFilePath = 'remote_file.txt';

// Call the method you want to test
$result = $this->oracleObject->uploadFileToOracleObjectStorage($localFilePath, $remoteFilePath);

// Assert that the upload was successful (you can customize this assertion)
$this->assertTrue($result);
}

public function testDownloadFileFromOracleObjectStorage()
{
// Implement your test for the download method here
$remoteFilePath = 'remote_file.txt';
$localFilePath = 'downloaded_file.txt';

// Call the method you want to test
$result = $this->oracleObject->downloadFileFromOracleObjectStorage($remoteFilePath, $localFilePath);

// Assert that the download was successful (you can customize this assertion)
$this->assertTrue($result);
}

public function testDeleteFileFromOracleObjectStorage()
{
// Implement your test for the delete method here
$remoteFilePath = 'remote_file.txt';

// Call the method you want to test
$result = $this->oracleObject->deleteFileFromOracleObjectStorage($remoteFilePath);

// Assert that the delete was successful (you can customize this assertion)
$this->assertTrue($result);
}
}
Loading