summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Araujo Sobrinho <marcos.sobrinho@truckpad.com.br>2017-11-14 16:12:52 -0200
committerMarcos Araujo Sobrinho <marcos.sobrinho@truckpad.com.br>2017-11-14 16:12:52 -0200
commita155254c50536a3cd2c70441ad147524e537ff1f (patch)
treec4308d6048fb19b8f0b410632e5cfd8bc075b7d1
parent48913bf78706f5926f8169906d79618ffcbd1299 (diff)
downloadwwwsqldesigner-a155254c50536a3cd2c70441ad147524e537ff1f.zip
wwwsqldesigner-a155254c50536a3cd2c70441ad147524e537ff1f.tar.gz
wwwsqldesigner-a155254c50536a3cd2c70441ad147524e537ff1f.tar.bz2
AWS S3 Support
-rw-r--r--.gitmodules3
m---------backend/php-s3/amazon-s3-php0
-rw-r--r--backend/php-s3/index.php42
-rw-r--r--js/config.js4
4 files changed, 47 insertions, 2 deletions
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
+Subproject bfc42ea0c0b0aac3484f0a9fbc3e9975d730d08
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 @@
+<?php
+ $access_key = $_ENV['ACCESS_KEY'];
+ $secret_key = $_ENV['SECRET_KEY'];
+ $bucket = $_ENV['BUCKET'];
+ $path = 'schemas';
+ if (!$access_key || !$secret_key || !$bucket) {
+ header("HTTP/1.0 501 Credentials not provided!");
+ return;
+ }
+
+ include('amazon-s3-php/src/S3.php');
+ $client = new S3($access_key, $secret_key, "s3-us-west-2.amazonaws.com");
+
+ $a = (isset($_GET["action"]) ? $_GET["action"] : false);
+ switch ($a) {
+ case "list":
+ $response = $client->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,