12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- class PutFileAccessTokenAction implements IAction {
- public function execute() {
- if(!Authorize::isLoggedIn()) {
- return array("error" => "Access not authorized");
- }
-
- $projectId = $_POST['project_id'] ?? $_GET['project_id'];
- $filePath = $_POST['filePath'] ?? $_GET['filePath'];
- $fileType = $_POST['fileType'] ?? $_GET['fileType'];
- $isResume = ($_POST['resume'] ?? $_GET['resume'] ?? false) == "true";
- $database = SqliteDatabase::getSingleton();
- $projects = $database->queryArray("SELECT rowid AS project_id, * FROM projects WHERE project_id = ".$projectId .";");
- $project = $projects[0];
- $bucket = $project['bucket'];
- $folder = $project['folder'];
-
- $folderTree = explode("/", $filePath);
- array_shift($folderTree);
- $filePath = implode("/", $folderTree);
-
- $awsOauth = new AWSOAuth();
- $region = BucketGetRegion::get($bucket);
- $uploadAuthData = $awsOauth->putFileSecureParams($bucket, $region, "/" . $folder. "/". $filePath);
- $uploadAuthData['status'] = 1;
- $uploadAuthData['headers']['content-type'] = $fileType;
- unset($uploadAuthData['canonical_request']);
- unset($uploadAuthData['string_to_sign']);
- unset($uploadAuthData['signature']);
- return $uploadAuthData;
- }
- }
|