Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/storage.svg)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)

Utopia Storage library is simple and lite library for managing application storage. It supports multiple storage adapters. We already support AWS S3 storage, Digitalocean Spaces storage and Backblaze B2 Cloud storage. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).
Utopia Storage library is simple and lite library for managing application storage. It supports multiple storage adapters. We already support AWS S3 storage, Digitalocean Spaces storage, Backblaze B2 Cloud storage, Linode Object storage and Wasabi Cloud storage. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).

This library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project.

Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions src/Storage/Device/Linode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Utopia\Storage\Device;

use Utopia\Storage\Device\S3;

class Linode 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.'.'.'linodeobjects.com';
}

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

/**
* @return string
*/
public function getDescription(): string
{
return 'Linode Object Storage';
}
}
3 changes: 2 additions & 1 deletion src/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Storage
const DEVICE_S3 = 'S3';
const DEVICE_DO_SPACES = 'DOSpaces';
const DEVICE_BACKBLAZE = 'BackBlaze';
const DEVICE_LINODE= 'Linode';

/**
* Devices.
Expand Down Expand Up @@ -119,4 +120,4 @@ public static function human(int $bytes, $decimals = 2, $system = 'metric')

return sprintf("%.{$decimals}f%s", $bytes / pow($mod, $factor), $units[$system][$factor]);
}
}
}
30 changes: 30 additions & 0 deletions tests/Storage/Device/LinodeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Utopia\Tests;

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

class LinodeTest extends S3Base
{
protected function init(): void
{
$this->root = 'root';
$key = $_SERVER['LINODE_ACCESS_KEY'] ?? '';
$secret = $_SERVER['LINODE_SECRET'] ?? '';
$bucket = 'everly-test';

$this->object = new Linode($this->root, $key, $secret, $bucket, Linode::EU_CENTRAL_1, Linode::ACL_PRIVATE);

}

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

protected function getAdapterDescription(): string
{
return 'Linode Object Storage';
}
}