BLUE-17: added support for S3 cloud storage (including DreamObjects, which uses an S3-compatible API)
This commit is contained in:
parent
1c0d2af035
commit
35758d338a
139
app/AlbumSources/AmazonS3Source.php
Normal file
139
app/AlbumSources/AmazonS3Source.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\AlbumSources;
|
||||
|
||||
use App\Photo;
|
||||
use Guzzle\Http\EntityBody;
|
||||
use Guzzle\Http\Exception\ClientErrorResponseException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AmazonS3Source extends AlbumSourceBase implements IAlbumSource
|
||||
{
|
||||
/**
|
||||
* Deletes an entire album's media contents.
|
||||
* @return void
|
||||
*/
|
||||
public function deleteAlbumContents()
|
||||
{
|
||||
// Because all photos live in a single bucket, there is nothing "global" to delete for the entire album
|
||||
// The delete routine will have already removed all photos
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a thumbnail file for a photo.
|
||||
* @param Photo $photo Photo to delete the thumbnail from.
|
||||
* @param string $thumbnail Thumbnail to delete (or null to delete the original.)
|
||||
* @return void
|
||||
*/
|
||||
public function deleteThumbnail(Photo $photo, $thumbnail = null)
|
||||
{
|
||||
$photoPath = $this->getPathToPhoto($photo, $thumbnail);
|
||||
|
||||
try
|
||||
{
|
||||
$this->getClient()->deleteObject([
|
||||
'Bucket' => $this->configuration->container_name,
|
||||
'Key' => $this->getPathToPhoto($photo, $thumbnail)
|
||||
]);
|
||||
}
|
||||
catch (ClientErrorResponseException $ex)
|
||||
{
|
||||
// Don't worry if the file no longer exists
|
||||
Log::warning('Failed deleting image from S3.', ['error' => $ex->getMessage(), 'path' => $photoPath]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the contents of a thumbnail for a photo.
|
||||
* @param Photo $photo Photo to fetch the thumbnail for.
|
||||
* @param string $thumbnail Thumbnail to fetch (or null to fetch the original.)
|
||||
* @return EntityBody
|
||||
*/
|
||||
public function fetchPhotoContent(Photo $photo, $thumbnail = null)
|
||||
{
|
||||
$tempFile = tempnam(sys_get_temp_dir(), 'BlueTwilight_');
|
||||
|
||||
try
|
||||
{
|
||||
$this->getClient()->getObject([
|
||||
'Bucket' => $this->configuration->container_name,
|
||||
'Key' => $this->getPathToPhoto($photo, $thumbnail),
|
||||
'SaveAs' => $tempFile
|
||||
]);
|
||||
|
||||
return EntityBody::factory(fopen($tempFile, 'r+'));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@unlink($tempFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this album source.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'global.album_sources.amazon_s3';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the absolute URL to the given photo file.
|
||||
* @param Photo $photo Photo to get the URL to.
|
||||
* @param string $thumbnail Thumbnail to get the image to.
|
||||
* @return string
|
||||
*/
|
||||
public function getUrlToPhoto(Photo $photo, $thumbnail = null)
|
||||
{
|
||||
return $this->getClient()->getObjectUrl($this->configuration->container_name, $this->getPathToPhoto($photo, $thumbnail));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a generated thumbnail to its permanent location.
|
||||
* @param Photo $photo Photo the image relates to.
|
||||
* @param string $tempFilename Filename containing the image.
|
||||
* @param string $thumbnail Name of the thumbnail (or null for the original.)
|
||||
* @return mixed
|
||||
*/
|
||||
public function saveThumbnail(Photo $photo, $tempFilename, $thumbnail = null)
|
||||
{
|
||||
$photoPath = $this->getPathToPhoto($photo, $thumbnail);
|
||||
|
||||
$this->getClient()->upload($this->configuration->container_name, $photoPath, fopen($tempFilename, 'r+'), 'public-read');
|
||||
}
|
||||
|
||||
private function getClient()
|
||||
{
|
||||
$config = [
|
||||
'credentials' => new \Aws\Credentials\Credentials(
|
||||
decrypt($this->configuration->access_key),
|
||||
decrypt($this->configuration->secret_key)
|
||||
),
|
||||
'version' => 'latest',
|
||||
'region' => $this->configuration->service_region
|
||||
];
|
||||
|
||||
if (!empty($this->configuration->auth_url) && parse_url($this->configuration->auth_url) !== false)
|
||||
{
|
||||
$config['endpoint'] = $this->configuration->auth_url;
|
||||
}
|
||||
|
||||
return new \Aws\S3\S3Client($config);
|
||||
}
|
||||
|
||||
private function getOriginalsFolder()
|
||||
{
|
||||
return '_originals';
|
||||
}
|
||||
|
||||
private function getPathToPhoto(Photo $photo, $thumbnail = null)
|
||||
{
|
||||
return sprintf(
|
||||
'%s/%s/%s',
|
||||
$this->album->url_alias,
|
||||
is_null($thumbnail) ? $this->getOriginalsFolder() : $thumbnail,
|
||||
$photo->storage_file_name
|
||||
);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\AlbumSources;
|
||||
|
||||
use App\Photo;
|
||||
use Guzzle\Http\EntityBody;
|
||||
use Guzzle\Http\Exception\ClientErrorResponseException;
|
||||
@ -10,7 +11,7 @@ use OpenCloud\OpenStack;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
||||
/**
|
||||
* Driver for managing files on the local filesystem.
|
||||
* Driver for managing files on an OpenStack Keystone+Swift compatible platform.
|
||||
* @package App\AlbumSources
|
||||
*/
|
||||
class OpenStackSource extends AlbumSourceBase implements IAlbumSource
|
||||
|
@ -3,9 +3,11 @@
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Album;
|
||||
use App\AlbumSources\AmazonS3Source;
|
||||
use App\AlbumSources\IAlbumSource;
|
||||
use App\AlbumSources\LocalFilesystemSource;
|
||||
use App\AlbumSources\OpenStackSource;
|
||||
use App\AlbumSources\OpenStackV1Source;
|
||||
use App\Configuration;
|
||||
|
||||
class ConfigHelper
|
||||
@ -31,6 +33,7 @@ class ConfigHelper
|
||||
|
||||
$classes = [
|
||||
LocalFilesystemSource::class,
|
||||
AmazonS3Source::class,
|
||||
OpenStackSource::class
|
||||
];
|
||||
foreach ($classes as $class)
|
||||
|
@ -14,10 +14,17 @@ use Illuminate\Support\Facades\View;
|
||||
|
||||
class StorageController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $encryptedFields;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
View::share('is_admin', true);
|
||||
|
||||
$this->encryptedFields = ['password', 'access_key', 'secret_key'];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +86,9 @@ class StorageController extends Controller
|
||||
'service_name',
|
||||
'service_region',
|
||||
'container_name',
|
||||
'cdn_url'
|
||||
'cdn_url',
|
||||
'access_key',
|
||||
'secret_key'
|
||||
]));
|
||||
$storage->is_active = true;
|
||||
$storage->is_default = (strtolower($request->get('is_default')) == 'on');
|
||||
@ -90,9 +99,12 @@ class StorageController extends Controller
|
||||
unset($storage->location);
|
||||
}
|
||||
|
||||
if (isset($storage->password) && !empty($storage->password))
|
||||
foreach ($this->encryptedFields as $field)
|
||||
{
|
||||
$storage->password = encrypt($storage->password);
|
||||
if (isset($storage->$field) && !empty($storage->$field))
|
||||
{
|
||||
$storage->$field = encrypt($storage->$field);
|
||||
}
|
||||
}
|
||||
|
||||
$storage->save();
|
||||
@ -165,9 +177,12 @@ class StorageController extends Controller
|
||||
App::abort(404);
|
||||
}
|
||||
|
||||
if (isset($storage->password) && strlen($storage->password) > 0)
|
||||
foreach ($this->encryptedFields as $field)
|
||||
{
|
||||
$storage->password = decrypt($storage->password);
|
||||
if (isset($storage->$field) && !empty($storage->$field))
|
||||
{
|
||||
$storage->$field = decrypt($storage->$field);
|
||||
}
|
||||
}
|
||||
|
||||
return Theme::render('admin.edit_storage', ['storage' => $storage]);
|
||||
@ -199,7 +214,9 @@ class StorageController extends Controller
|
||||
'service_name',
|
||||
'service_region',
|
||||
'container_name',
|
||||
'cdn_url'
|
||||
'cdn_url',
|
||||
'access_key',
|
||||
'secret_key'
|
||||
]));
|
||||
$storage->is_active = (strtolower($request->get('is_active')) == 'on');
|
||||
$storage->is_default = (strtolower($request->get('is_default')) == 'on');
|
||||
@ -209,9 +226,12 @@ class StorageController extends Controller
|
||||
$storage->is_default = false;
|
||||
}
|
||||
|
||||
if (isset($storage->password) && !empty($storage->password))
|
||||
foreach ($this->encryptedFields as $field)
|
||||
{
|
||||
$storage->password = encrypt($storage->password);
|
||||
if (isset($storage->$field) && !empty($storage->$field))
|
||||
{
|
||||
$storage->$field = encrypt($storage->$field);
|
||||
}
|
||||
}
|
||||
|
||||
$storage->save();
|
||||
|
@ -28,7 +28,9 @@ class Storage extends Model
|
||||
'service_name',
|
||||
'service_region',
|
||||
'container_name',
|
||||
'cdn_url'
|
||||
'cdn_url',
|
||||
'access_key',
|
||||
'secret_key'
|
||||
];
|
||||
|
||||
public function albums()
|
||||
|
@ -9,7 +9,8 @@
|
||||
"laravel/framework": "5.3.*",
|
||||
"laravelcollective/html": "5.3.*",
|
||||
"rackspace/php-opencloud": "^1.16",
|
||||
"doctrine/dbal": "^2.5"
|
||||
"doctrine/dbal": "^2.5",
|
||||
"aws/aws-sdk-php": "^3.19"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "~1.4",
|
||||
|
360
composer.lock
generated
360
composer.lock
generated
@ -4,9 +4,89 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "a5bcf947cf94af4452c3bbb308f3231c",
|
||||
"content-hash": "8da0234bc3f5e6de745254c161031630",
|
||||
"hash": "4b8d9cec22ab6524754ddb5904e71624",
|
||||
"content-hash": "3e0b0397103bcceb7b26f8cb95b6239f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
"version": "3.19.22",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||
"reference": "04d2a027cac94674b52dfb4d68667bfe225b0fb5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/04d2a027cac94674b52dfb4d68667bfe225b0fb5",
|
||||
"reference": "04d2a027cac94674b52dfb4d68667bfe225b0fb5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^5.3.1|^6.2.1",
|
||||
"guzzlehttp/promises": "~1.0",
|
||||
"guzzlehttp/psr7": "~1.3.1",
|
||||
"mtdowling/jmespath.php": "~2.2",
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"andrewsville/php-token-reflection": "^1.4",
|
||||
"aws/aws-php-sns-message-validator": "~1.0",
|
||||
"behat/behat": "~3.0",
|
||||
"doctrine/cache": "~1.4",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-spl": "*",
|
||||
"nette/neon": "^2.3",
|
||||
"phpunit/phpunit": "~4.0|~5.0",
|
||||
"psr/cache": "^1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"aws/aws-php-sns-message-validator": "To validate incoming SNS notifications",
|
||||
"doctrine/cache": "To use the DoctrineCacheAdapter",
|
||||
"ext-curl": "To send requests using cURL",
|
||||
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Aws\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Amazon Web Services",
|
||||
"homepage": "http://aws.amazon.com"
|
||||
}
|
||||
],
|
||||
"description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project",
|
||||
"homepage": "http://aws.amazon.com/sdkforphp",
|
||||
"keywords": [
|
||||
"amazon",
|
||||
"aws",
|
||||
"cloud",
|
||||
"dynamodb",
|
||||
"ec2",
|
||||
"glacier",
|
||||
"s3",
|
||||
"sdk"
|
||||
],
|
||||
"time": "2016-11-02 22:24:48"
|
||||
},
|
||||
{
|
||||
"name": "classpreloader/classpreloader",
|
||||
"version": "3.0.0",
|
||||
@ -656,6 +736,177 @@
|
||||
"abandoned": "guzzlehttp/guzzle",
|
||||
"time": "2014-01-28 22:29:15"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "6.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/ebf29dee597f02f09f4d5bbecc68230ea9b08f60",
|
||||
"reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/promises": "^1.0",
|
||||
"guzzlehttp/psr7": "^1.3.1",
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"phpunit/phpunit": "^4.0",
|
||||
"psr/log": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "Guzzle is a PHP HTTP client library",
|
||||
"homepage": "http://guzzlephp.org/",
|
||||
"keywords": [
|
||||
"client",
|
||||
"curl",
|
||||
"framework",
|
||||
"http",
|
||||
"http client",
|
||||
"rest",
|
||||
"web service"
|
||||
],
|
||||
"time": "2016-10-08 15:01:37"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/promises.git",
|
||||
"reference": "c10d860e2a9595f8883527fa0021c7da9e65f579"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579",
|
||||
"reference": "c10d860e2a9595f8883527fa0021c7da9e65f579",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Promise\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "Guzzle promises library",
|
||||
"keywords": [
|
||||
"promise"
|
||||
],
|
||||
"time": "2016-05-18 16:56:05"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "1.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
|
||||
"reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"psr/http-message": "~1.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Psr7\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "PSR-7 message implementation",
|
||||
"keywords": [
|
||||
"http",
|
||||
"message",
|
||||
"stream",
|
||||
"uri"
|
||||
],
|
||||
"time": "2016-06-24 23:00:38"
|
||||
},
|
||||
{
|
||||
"name": "jakub-onderka/php-console-color",
|
||||
"version": "0.1",
|
||||
@ -1215,6 +1466,61 @@
|
||||
],
|
||||
"time": "2016-01-26 21:23:30"
|
||||
},
|
||||
{
|
||||
"name": "mtdowling/jmespath.php",
|
||||
"version": "2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jmespath/jmespath.php.git",
|
||||
"reference": "192f93e43c2c97acde7694993ab171b3de284093"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/192f93e43c2c97acde7694993ab171b3de284093",
|
||||
"reference": "192f93e43c2c97acde7694993ab171b3de284093",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/jp.php"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"JmesPath\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/JmesPath.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "Declaratively specify how to extract elements from a JSON document",
|
||||
"keywords": [
|
||||
"json",
|
||||
"jsonpath"
|
||||
],
|
||||
"time": "2016-01-05 18:25:05"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "1.21.0",
|
||||
@ -1361,6 +1667,56 @@
|
||||
],
|
||||
"time": "2016-04-03 06:00:07"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-message.git",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Message\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP messages",
|
||||
"homepage": "https://github.com/php-fig/http-message",
|
||||
"keywords": [
|
||||
"http",
|
||||
"http-message",
|
||||
"psr",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response"
|
||||
],
|
||||
"time": "2016-08-06 14:39:51"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.0.1",
|
||||
|
@ -40,7 +40,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => env('APP_DEBUG', true),
|
||||
'debug' => env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddS3StorageFields extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('storages', function (Blueprint $table) {
|
||||
$table->text('access_key')->nullable();
|
||||
$table->text('secret_key')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('storages', function (Blueprint $table) {
|
||||
$table->dropColumn('secret_key');
|
||||
$table->dropColumn('access_key');
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class IncreasePasswordField extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('storages', function (Blueprint $table) {
|
||||
$table->text('password')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('storages', function (Blueprint $table) {
|
||||
$table->string('password')->change();
|
||||
});
|
||||
}
|
||||
}
|
@ -29,12 +29,16 @@ return [
|
||||
'settings_hotlink_protection_help' => 'With this option enabled, direct linking to images is not allowed. Photos can only be viewed through Blue Twilight.',
|
||||
'settings_restrict_originals_download' => 'Restrict access to original images',
|
||||
'settings_restrict_originals_download_help' => 'With this option enabled, only the photo\'s owner can download the original high-resolution images.',
|
||||
'storage_access_key_label' => 'Access key:',
|
||||
'storage_active_label' => 'Location is active. Uncheck to prevent creating new albums in this location.',
|
||||
'storage_auth_url_label' => 'Authentication URL:',
|
||||
'storage_bucket_name_label' => 'Bucket name:',
|
||||
'storage_cdn_url_label' => 'Public CDN URL (if supported and enabled):',
|
||||
'storage_container_name_label' => 'Container name:',
|
||||
'storage_driver_label' => 'Storage driver:',
|
||||
'storage_endpoint_url_label' => 'Endpoint URL (leave blank if using Amazon):',
|
||||
'storage_location_label' => 'Physical location:',
|
||||
'storage_secret_key_label' => 'Secret key:',
|
||||
'storage_service_name_label' => 'Service name:',
|
||||
'storage_service_region_label' => 'Region:',
|
||||
'storage_tenant_name_label' => 'Tenant:',
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
return [
|
||||
'album_sources' => [
|
||||
'amazon_s3' => 'Amazon S3 (or S3-compatible)',
|
||||
'filesystem' => 'Local filesystem',
|
||||
'openstack' => 'OpenStack cloud storage'
|
||||
],
|
||||
|
@ -40,7 +40,7 @@
|
||||
</div>
|
||||
|
||||
<div id="storage-options">
|
||||
<div id="local-filesystem" data-bind="visible: selectedLocation() == 'LocalFilesystemSource'">
|
||||
<div data-bind="visible: selectedLocation() == 'LocalFilesystemSource'">
|
||||
<div class="form-group{{ $errors->has('location') ? ' has-error' : '' }}">
|
||||
{!! Form::label('location', trans('forms.storage_location_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('location', old('location', $filesystem_default_location), ['class' => 'form-control']) !!}
|
||||
@ -53,7 +53,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="local-filesystem" data-bind="visible: selectedLocation() == 'OpenStackSource'">
|
||||
<div data-bind="visible: selectedLocation() == 'OpenStackV1Source'">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('auth_url') ? ' has-error' : '' }}">
|
||||
@ -157,6 +157,115 @@
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-bind="visible: selectedLocation() == 'OpenStackSource'">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('auth_url') ? ' has-error' : '' }}">
|
||||
{!! Form::label('auth_url', trans('forms.storage_auth_url_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('auth_url', old('auth_url'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('auth_url'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('auth_url') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('tenant_name') ? ' has-error' : '' }}">
|
||||
{!! Form::label('tenant_name', trans('forms.storage_tenant_name_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('tenant_name', old('tenant_name'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('tenant_name'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('tenant_name') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
|
||||
{!! Form::label('username', trans('forms.username_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('username', old('username'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('username'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('username') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
{!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('password', old('password'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('password'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('service_name') ? ' has-error' : '' }}">
|
||||
{!! Form::label('service_name', trans('forms.storage_service_name_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('service_name', old('service_name'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('service_name'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('service_name') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('service_region') ? ' has-error' : '' }}">
|
||||
{!! Form::label('service_region', trans('forms.storage_service_region_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('service_region', old('service_region'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('service_region'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('service_region') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('container_name') ? ' has-error' : '' }}">
|
||||
{!! Form::label('container_name', trans('forms.storage_container_name_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('container_name', old('container_name'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('container_name'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('container_name') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('cdn_url') ? ' has-error' : '' }}">
|
||||
{!! Form::label('cdn_url', trans('forms.storage_cdn_url_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('cdn_url', old('cdn_url'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('cdn_url'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('cdn_url') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-bind="visible: selectedLocation() == 'AmazonS3Source'">
|
||||
@include(Theme::viewName('partials.admin_storages_amazon_s3_options'))
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
|
@ -154,6 +154,10 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($storage->source == 'AmazonS3Source')
|
||||
@include(Theme::viewName('partials.admin_storages_amazon_s3_options'))
|
||||
@endif
|
||||
|
||||
<div class="form-actions">
|
||||
<a href="{{ route('storage.index') }}" class="btn btn-default">@lang('forms.cancel_action')</a>
|
||||
{!! Form::submit(trans('forms.save_action'), ['class' => 'btn btn-success']) !!}
|
||||
|
@ -37,8 +37,11 @@
|
||||
@if ($storage->is_default) <i class="fa fa-fw fa-check text-success"></i>@endif
|
||||
@if (!$storage->is_active) <i class="fa fa-fw fa-minus-circle text-danger"></i>@endif
|
||||
</span><br/>
|
||||
<span style="color: #888; font-style: italic;">
|
||||
@if ($storage->source == 'LocalFilesystemSource'){{ $storage->location }}@endif
|
||||
@if ($storage->source == 'OpenStackSource'){{ $storage->container_name }} - {{ $storage->service_name }}, {{ $storage->service_region }}@endif
|
||||
@if ($storage->source == 'AmazonS3Source'){{ $storage->container_name }} - {{ $storage->service_region }}@endif
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a href="{{ route('storage.edit', ['id' => $storage->id]) }}" class="btn btn-default">@lang('forms.edit_action')</a>
|
||||
|
@ -0,0 +1,64 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('access_key') ? ' has-error' : '' }}">
|
||||
{!! Form::label('access_key', trans('forms.storage_access_key_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('access_key', old('access_key'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('access_key'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('access_key') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('secret_key') ? ' has-error' : '' }}">
|
||||
{!! Form::label('secret_key', trans('forms.storage_secret_key_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('secret_key', old('secret_key'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('secret_key'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('secret_key') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('container_name') ? ' has-error' : '' }}">
|
||||
{!! Form::label('container_name', trans('forms.storage_bucket_name_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('container_name', old('container_name'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('container_name'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('container_name') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group{{ $errors->has('service_region') ? ' has-error' : '' }}">
|
||||
{!! Form::label('service_region', trans('forms.storage_service_region_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('service_region', old('service_region'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('service_region'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('service_region') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('auth_url') ? ' has-error' : '' }}">
|
||||
{!! Form::label('auth_url', trans('forms.storage_endpoint_url_label'), ['class' => 'control-label']) !!}
|
||||
{!! Form::text('auth_url', old('auth_url'), ['class' => 'form-control']) !!}
|
||||
|
||||
@if ($errors->has('auth_url'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('auth_url') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
@ -13,6 +13,24 @@
|
||||
|
||||
Auth::routes();
|
||||
|
||||
Route::get('/openstack-test', function ()
|
||||
{
|
||||
$credentials = new \Aws\Credentials\Credentials('vyUv2MDny84Q3VD6Zvg0', 'TuQSzRbx3f6Rmnnf_N4LXod5DCtgUfGwprot7UpQ');
|
||||
|
||||
$client = new \Aws\S3\S3Client(array(
|
||||
'endpoint' => 'https://objects-us-west-1.dream.io',
|
||||
'credentials' => $credentials,
|
||||
'version' => 'latest',
|
||||
'region' => 'xxx'
|
||||
));
|
||||
|
||||
$blist = $client->listBuckets();
|
||||
echo " Buckets belonging to " . $blist['Owner']['ID'] . ":\n";
|
||||
foreach ($blist['Buckets'] as $b) {
|
||||
echo "{$b['Name']}\t{$b['CreationDate']}\n";
|
||||
}
|
||||
});
|
||||
|
||||
// Administration
|
||||
Route::group(['prefix' => 'admin'], function () {
|
||||
Route::get('/', 'Admin\DefaultController@index')->name('admin');
|
||||
|
Loading…
Reference in New Issue
Block a user