12345678910111213141516171819202122232425 |
- <?php
- class GetFileAccessTokenAction implements IAction {
- public function execute() {
- if(!Authorize::isLoggedIn()) {
- return array("error" => "Access not authorized");
- }
- $database = SqliteDatabase::getSingleton();
- $clientId = $_SESSION['client_id'];
- $projectId = isset($_POST['project_id']) ? $_POST['project_id'] : $_GET['project_id'];
- $projects = $database->queryArray("SELECT rowid AS project_id, * FROM projects WHERE project_id IN (SELECT project_id FROM account_projects WHERE account_id = ".$clientId." AND project_id = ".$projectId .") LIMIT 1;");
- $project = $projects[0];
- $awsOauth = new AWSOAuth();
- $filename = isset($_POST['filename']) ? $_POST['filename']: $_GET['filename'];
- $url = "https://".BUCKET_PREFIX . $project['bucket'].".s3.amazonaws.com/" . $project['folder'] . $filename;
- $params = $awsOauth->getFileSecureParams(BUCKET_PREFIX . $project['bucket'], $project['folder'] . $filename);
- return array("url" => $url,
- "params" => $params,
- "full" => $url . "?" . $params);
- }
- }
|