GetFileAccessTokenAction2.class.php 1.1 KB

1234567891011121314151617181920212223242526272829
  1. <?php
  2. class GetFileAccessTokenAction2 implements IAction {
  3. public function execute() {
  4. if(!Authorize::isLoggedIn()) {
  5. return array("error" => "Access not authorized");
  6. }
  7. $database = SqliteDatabase::getSingleton();
  8. $clientId = $_SESSION['client_id'] ?? $_POST['client_id'] ?? $_GET['client_id'];
  9. $projectId = $_POST['project_id'] ?? $_GET['project_id'];
  10. $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;");
  11. $project = $projects[0];
  12. $bucket = $project['bucket'];
  13. $folder = $project['folder'];
  14. $awsOauth = new AWSOAuth();
  15. $filename = $_POST['filename'] ?? $_GET['filename'];
  16. $region = BucketGetRegion::get($bucket);
  17. $params = $awsOauth->getFileSecureParams2($bucket, $region, "/" . $folder . $filename);
  18. $params['unity_headers'] = array();
  19. foreach($params['headers'] as $key => $value) {
  20. $params['unity_headers'][str_ireplace("-", "_", $key)] = $value;
  21. }
  22. return $params;
  23. }
  24. }