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

feat: add yandex storage adapter #102

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
56 changes: 56 additions & 0 deletions src/Storage/Device/Yandex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Utopia\Storage\Device;

use Utopia\Storage\Storage;

class Yandex extends S3
{
/**
* Regions constants
*/
const RU_CENTRAL_A = 'ru-central1-a';

const RU_CENTRAL_B = 'ru-central1-b';

const RU_CENTRAL_C = 'ru-central1-c';

/**
* YandexStorage Constructor
*
* @param string $root
* @param string $accessKey
* @param string $secretKey
* @param string $bucket
* @param string $acl
*/
public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::RU_CENTRAL_A, string $acl = self::ACL_PRIVATE)
{
parent::__construct($root, $accessKey, $secretKey, $bucket, $region, $acl);
$this->headers['host'] = $bucket.'.storage.yandexcloud.net';
}

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

/**
* @return string
*/
public function getDescription(): string
{
return 'Yandex Storage';
}

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

const DEVICE_WASABI = 'wasabi';

const DEVICE_YANDEX = 'yandex';

const DEVICE_BACKBLAZE = 'backblaze';

const DEVICE_LINODE = 'linode';
Expand Down
35 changes: 35 additions & 0 deletions tests/Storage/Device/YandexTest.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\Yandex;
use Utopia\Tests\Storage\S3Base;

class YandexTest extends S3Base
{
protected function init(): void
{
$this->root = '/root';
$key = $_SERVER['YANDEX_ACCESS_KEY'] ?? '';
$secret = $_SERVER['YANDEX_SECRET'] ?? '';
$bucket = 'utopia-storage-tests';
$region = 'ru-central1-a';

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

protected function getAdapterName(): string
{
return 'Yandex Storage';
}

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

protected function getAdapterDescription(): string
{
return 'Yandex Storage';
}
}
Loading