diff --git a/app/AlbumSources/AmazonS3Source.php b/app/AlbumSources/AmazonS3Source.php new file mode 100644 index 0000000..9563d18 --- /dev/null +++ b/app/AlbumSources/AmazonS3Source.php @@ -0,0 +1,139 @@ +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 + ); + } +} \ No newline at end of file diff --git a/app/AlbumSources/OpenStackSource.php b/app/AlbumSources/OpenStackSource.php index 4e564e7..630f360 100644 --- a/app/AlbumSources/OpenStackSource.php +++ b/app/AlbumSources/OpenStackSource.php @@ -1,6 +1,7 @@ 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(); diff --git a/app/Storage.php b/app/Storage.php index 09e4094..cd7cd42 100644 --- a/app/Storage.php +++ b/app/Storage.php @@ -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() diff --git a/composer.json b/composer.json index 4d91f83..54ffa4c 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 3ac8b41..cf01d45 100644 --- a/composer.lock +++ b/composer.lock @@ -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", diff --git a/config/app.php b/config/app.php index cb9c4d8..f9a34c5 100644 --- a/config/app.php +++ b/config/app.php @@ -40,7 +40,7 @@ return [ | */ - 'debug' => env('APP_DEBUG', true), + 'debug' => env('APP_DEBUG', false), /* |-------------------------------------------------------------------------- diff --git a/database/migrations/2016_11_03_102913_add_s3_storage_fields.php b/database/migrations/2016_11_03_102913_add_s3_storage_fields.php new file mode 100644 index 0000000..0b2d9d2 --- /dev/null +++ b/database/migrations/2016_11_03_102913_add_s3_storage_fields.php @@ -0,0 +1,34 @@ +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'); + }); + } +} diff --git a/database/migrations/2016_11_03_102929_increase_password_field.php b/database/migrations/2016_11_03_102929_increase_password_field.php new file mode 100644 index 0000000..3dc7f36 --- /dev/null +++ b/database/migrations/2016_11_03_102929_increase_password_field.php @@ -0,0 +1,32 @@ +text('password')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('storages', function (Blueprint $table) { + $table->string('password')->change(); + }); + } +} diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index ec6b46a..5b35dfa 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -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:', diff --git a/resources/lang/en/global.php b/resources/lang/en/global.php index 7399a80..4905226 100644 --- a/resources/lang/en/global.php +++ b/resources/lang/en/global.php @@ -1,6 +1,7 @@ [ + 'amazon_s3' => 'Amazon S3 (or S3-compatible)', 'filesystem' => 'Local filesystem', 'openstack' => 'OpenStack cloud storage' ], diff --git a/resources/views/themes/base/admin/create_storage.blade.php b/resources/views/themes/base/admin/create_storage.blade.php index 916f4b3..2cf7ac4 100644 --- a/resources/views/themes/base/admin/create_storage.blade.php +++ b/resources/views/themes/base/admin/create_storage.blade.php @@ -40,7 +40,7 @@
-
+
{!! 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 @@
-
+
@@ -157,6 +157,115 @@ @endif
+ +
+
+
+
+ {!! 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')) + + {{ $errors->first('auth_url') }} + + @endif +
+
+
+
+ {!! 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')) + + {{ $errors->first('tenant_name') }} + + @endif +
+
+
+ +
+
+
+ {!! Form::label('username', trans('forms.username_label'), ['class' => 'control-label']) !!} + {!! Form::text('username', old('username'), ['class' => 'form-control']) !!} + + @if ($errors->has('username')) + + {{ $errors->first('username') }} + + @endif +
+
+
+
+ {!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!} + {!! Form::text('password', old('password'), ['class' => 'form-control']) !!} + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+
+ +
+
+
+ {!! 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')) + + {{ $errors->first('service_name') }} + + @endif +
+
+
+
+ {!! 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')) + + {{ $errors->first('service_region') }} + + @endif +
+
+
+ +
+ {!! 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')) + + {{ $errors->first('container_name') }} + + @endif +
+ +
+ {!! 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')) + + {{ $errors->first('cdn_url') }} + + @endif +
+
+ +
+ @include(Theme::viewName('partials.admin_storages_amazon_s3_options')) +
diff --git a/resources/views/themes/base/admin/edit_storage.blade.php b/resources/views/themes/base/admin/edit_storage.blade.php index c6fa492..34c7b88 100644 --- a/resources/views/themes/base/admin/edit_storage.blade.php +++ b/resources/views/themes/base/admin/edit_storage.blade.php @@ -154,6 +154,10 @@
@endif + @if ($storage->source == 'AmazonS3Source') + @include(Theme::viewName('partials.admin_storages_amazon_s3_options')) + @endif +
@lang('forms.cancel_action') {!! Form::submit(trans('forms.save_action'), ['class' => 'btn btn-success']) !!} diff --git a/resources/views/themes/base/admin/list_storage.blade.php b/resources/views/themes/base/admin/list_storage.blade.php index 433a08c..2cc177d 100644 --- a/resources/views/themes/base/admin/list_storage.blade.php +++ b/resources/views/themes/base/admin/list_storage.blade.php @@ -37,8 +37,11 @@ @if ($storage->is_default) @endif @if (!$storage->is_active) @endif
- @if ($storage->source == 'LocalFilesystemSource'){{ $storage->location }}@endif - @if ($storage->source == 'OpenStackSource'){{ $storage->container_name }} - {{ $storage->service_name }}, {{ $storage->service_region }}@endif + + @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 + @lang('forms.edit_action') diff --git a/resources/views/themes/base/partials/admin_storages_amazon_s3_options.blade.php b/resources/views/themes/base/partials/admin_storages_amazon_s3_options.blade.php new file mode 100644 index 0000000..3e1dff9 --- /dev/null +++ b/resources/views/themes/base/partials/admin_storages_amazon_s3_options.blade.php @@ -0,0 +1,64 @@ +
+
+
+ {!! 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')) + + {{ $errors->first('access_key') }} + + @endif +
+
+
+
+ {!! 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')) + + {{ $errors->first('secret_key') }} + + @endif +
+
+
+ +
+
+
+ {!! 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')) + + {{ $errors->first('container_name') }} + + @endif +
+
+
+
+ {!! 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')) + + {{ $errors->first('service_region') }} + + @endif +
+
+
+ +
+ {!! 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')) + + {{ $errors->first('auth_url') }} + + @endif +
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index ec5cd5a..3620e2c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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');