/** * @return string */ public static function getS3Url() { global $CFG; if (!isset($CFG->aws_s3_bucket)) { return ''; } if (isset($CFG->aws_cloudfront_url)) { return 'https://' . $CFG->aws_cloudfront_url . S3Util::getPrefix(); } return 'https://' . $CFG->aws_s3_bucket . '.s3.amazonaws.com' . S3Util::getPrefix(); }
/** * @param $file_contenthash * @param $file_statusamazon * @return string */ public function getTokenUrl($file_contenthash, $file_statusamazon) { $fileRelativeLocation = substr($this->path_from_hash($file_contenthash), 1); if (!class_exists('S3Util')) { require_once __DIR__ . '/S3Util.php'; } $file = S3Util::getPrefix() . $fileRelativeLocation; if ($file_statusamazon == 'public') { return S3Util::getS3Url() . $fileRelativeLocation; } return $this->client->getObjectUrl($this->bucket_name, $file, '+5 minutes'); }