php-s3 :: organizing env variables
This commit is contained in:
@@ -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'));
|
||||
$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");
|
||||
|
||||
Reference in New Issue
Block a user