AWS S3 Support
This commit is contained in:
@@ -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
|
||||||
Submodule
+1
Submodule backend/php-s3/amazon-s3-php added at bfc42ea0c0
@@ -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");
|
||||||
|
}
|
||||||
|
?>
|
||||||
+2
-2
@@ -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"],
|
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",
|
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"],
|
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-mysql"],
|
DEFAULT_BACKEND: ["php-s3"],
|
||||||
|
|
||||||
RELATION_THICKNESS: 2,
|
RELATION_THICKNESS: 2,
|
||||||
RELATION_SPACING: 15,
|
RELATION_SPACING: 15,
|
||||||
|
|||||||
Reference in New Issue
Block a user