1234567891011121314151617181920212223242526272829 |
- <?php
- class GetFileAccessTokenAction2 implements IAction {
- public function execute() {
- if(!Authorize::isLoggedIn()) {
- return array("error" => "Access not authorized");
- }
- $database = SqliteDatabase::getSingleton();
- $clientId = $_SESSION['client_id'] ?? $_POST['client_id'] ?? $_GET['client_id'];
- $projectId = $_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];
- $bucket = $project['bucket'];
- $folder = $project['folder'];
- $awsOauth = new AWSOAuth();
- $filename = $_POST['filename'] ?? $_GET['filename'];
- $region = BucketGetRegion::get($bucket);
- $params = $awsOauth->getFileSecureParams2($bucket, $region, "/" . $folder . $filename);
- $params['unity_headers'] = array();
- foreach($params['headers'] as $key => $value) {
- $params['unity_headers'][str_ireplace("-", "_", $key)] = $value;
- }
- return $params;
- }
- }
|