From a155254c50536a3cd2c70441ad147524e537ff1f Mon Sep 17 00:00:00 2001 From: Marcos Araujo Sobrinho Date: Tue, 14 Nov 2017 16:12:52 -0200 Subject: [PATCH 1/3] AWS S3 Support --- .gitmodules | 3 +++ backend/php-s3/amazon-s3-php | 1 + backend/php-s3/index.php | 42 ++++++++++++++++++++++++++++++++++++ js/config.js | 4 ++-- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 backend/php-s3/amazon-s3-php create mode 100644 backend/php-s3/index.php diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b7d3f0f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "backend/php-s3/amazon-s3-php"] + path = backend/php-s3/amazon-s3-php + url = https://github.com/ericnorris/amazon-s3-php.git diff --git a/backend/php-s3/amazon-s3-php b/backend/php-s3/amazon-s3-php new file mode 160000 index 0000000..bfc42ea --- /dev/null +++ b/backend/php-s3/amazon-s3-php @@ -0,0 +1 @@ +Subproject commit bfc42ea0c0b0aac3484f0a9fbc3e9975d730d089 diff --git a/backend/php-s3/index.php b/backend/php-s3/index.php new file mode 100644 index 0000000..71877ca --- /dev/null +++ b/backend/php-s3/index.php @@ -0,0 +1,42 @@ +getBucket($bucket); + foreach ($response->body->Contents as $content) { + $key = $content->Key; + if (0 === strpos($key, $path.'/') && $key != $path.'/') + echo substr($key, strlen($path)+1)."\n"; + } + break; + case "save": + $keyword = (isset($_GET["keyword"]) ? $_GET["keyword"] : ""); + $data = file_get_contents("php://input"); + $client->putObject($bucket, $path.'/'.$keyword, $data, array('Content-Type' => 'text/xml')); + header("HTTP/1.0 201 Created"); + break; + case "load": + $keyword = (isset($_GET["keyword"]) ? $_GET["keyword"] : ""); + $file = $client->getObject($bucket, $path.'/'.$keyword); + if ($file->body) { + header("Content-type: text/xml"); + echo $file->body; + } else { + header("HTTP/1.0 404 Not Found"); + } + break; + default: header("HTTP/1.0 501 Not Implemented"); + } +?> diff --git a/js/config.js b/js/config.js index 90ec791..a6cd241 100644 --- a/js/config.js +++ b/js/config.js @@ -5,8 +5,8 @@ var CONFIG = { AVAILABLE_LOCALES: ["ar", "cs", "de", "el", "en", "eo", "es", "fr", "hu", "it", "ja", "ko", "nl", "pl", "pt_BR", "ro", "ru", "sv", "zh"], DEFAULT_LOCALE: "en", - AVAILABLE_BACKENDS: ["php-mysql", "php-blank", "php-file", "php-sqlite", "php-mysql+file", "php-postgresql", "php-pdo", "perl-file", "php-cubrid", "asp-file", "web2py"], - DEFAULT_BACKEND: ["php-mysql"], + AVAILABLE_BACKENDS: ["php-s3", "php-mysql", "php-blank", "php-file", "php-sqlite", "php-mysql+file", "php-postgresql", "php-pdo", "perl-file", "php-cubrid", "asp-file", "web2py"], + DEFAULT_BACKEND: ["php-s3"], RELATION_THICKNESS: 2, RELATION_SPACING: 15, From 50d9c111a64eec2695c546f5df0286fdb6380ccf Mon Sep 17 00:00:00 2001 From: Marcelo Manzan Date: Tue, 14 Nov 2017 17:33:59 -0200 Subject: [PATCH 2/3] php-s3 :: organizing env variables --- backend/php-s3/index.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/backend/php-s3/index.php b/backend/php-s3/index.php index 71877ca..1839320 100644 --- a/backend/php-s3/index.php +++ b/backend/php-s3/index.php @@ -1,7 +1,8 @@ putObject($bucket, $path.'/'.$keyword, $data, array('Content-Type' => 'text/xml')); - header("HTTP/1.0 201 Created"); + $client->putObject($bucket, $path.'/'.$keyword, $data, array('Content-Type' => 'text/xml')); + header("HTTP/1.0 201 Created"); break; case "load": - $keyword = (isset($_GET["keyword"]) ? $_GET["keyword"] : ""); + $keyword = (isset($_GET["keyword"]) ? $_GET["keyword"] : ""); $file = $client->getObject($bucket, $path.'/'.$keyword); if ($file->body) { header("Content-type: text/xml"); From 839550377dea29d23c608c9fcf3e1dfcbca45705 Mon Sep 17 00:00:00 2001 From: Marcelo Manzan Date: Wed, 15 Nov 2017 09:55:11 -0200 Subject: [PATCH 3/3] Update config.js --- js/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/config.js b/js/config.js index a6cd241..20af61c 100644 --- a/js/config.js +++ b/js/config.js @@ -5,8 +5,8 @@ var CONFIG = { AVAILABLE_LOCALES: ["ar", "cs", "de", "el", "en", "eo", "es", "fr", "hu", "it", "ja", "ko", "nl", "pl", "pt_BR", "ro", "ru", "sv", "zh"], DEFAULT_LOCALE: "en", - AVAILABLE_BACKENDS: ["php-s3", "php-mysql", "php-blank", "php-file", "php-sqlite", "php-mysql+file", "php-postgresql", "php-pdo", "perl-file", "php-cubrid", "asp-file", "web2py"], - DEFAULT_BACKEND: ["php-s3"], + AVAILABLE_BACKENDS: ["php-mysql", "php-s3", "php-blank", "php-file", "php-sqlite", "php-mysql+file", "php-postgresql", "php-pdo", "perl-file", "php-cubrid", "asp-file", "web2py"], + DEFAULT_BACKEND: ["php-mysql"], RELATION_THICKNESS: 2, RELATION_SPACING: 15,