diff options
author | Marcelo Manzan <manzan@gmail.com> | 2017-11-14 17:33:59 -0200 |
---|---|---|
committer | Marcelo Manzan <manzan@gmail.com> | 2017-11-14 17:33:59 -0200 |
commit | 50d9c111a64eec2695c546f5df0286fdb6380ccf (patch) | |
tree | 714bf947d2184592d636e00a85ad57d745fc7320 | |
parent | a155254c50536a3cd2c70441ad147524e537ff1f (diff) | |
download | wwwsqldesigner-50d9c111a64eec2695c546f5df0286fdb6380ccf.zip wwwsqldesigner-50d9c111a64eec2695c546f5df0286fdb6380ccf.tar.gz wwwsqldesigner-50d9c111a64eec2695c546f5df0286fdb6380ccf.tar.bz2 |
php-s3 :: organizing env variables
-rw-r--r-- | backend/php-s3/index.php | 15 |
1 files 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 @@ <?php - $access_key = $_ENV['ACCESS_KEY']; - $secret_key = $_ENV['SECRET_KEY']; - $bucket = $_ENV['BUCKET']; + $access_key = $_ENV['AWS_S3_ID']; + $secret_key = $_ENV['AWS_S3_KEY']; + $bucket = $_ENV['BUCKET_NAME']; + $region = $_ENV['AWS_REGION']; $path = 'schemas'; if (!$access_key || !$secret_key || !$bucket) { header("HTTP/1.0 501 Credentials not provided!"); @@ -9,7 +10,7 @@ } include('amazon-s3-php/src/S3.php'); - $client = new S3($access_key, $secret_key, "s3-us-west-2.amazonaws.com"); + $client = new S3($access_key, $secret_key, 's3-'.$region.'.amazonaws.com'); $a = (isset($_GET["action"]) ? $_GET["action"] : false); switch ($a) { @@ -24,11 +25,11 @@ 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"); + $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"); |