post = $post; $this->replacer = $replacer; $this->mcloudPostUrl = str_replace( $replacer->getUploadsDirBaseUrl(), $replacer->getMcloudBaseUrl(), $post->getUrl() ); $this->mcloudPostBaseUrl = trailingslashit( str_replace($this->post->getBasename(), '', $this->mcloudPostUrl) ); $this->localPostBaseUrl = trailingslashit( str_replace($this->post->getBasename(), '', $this->post->getUrl()) ); $this->key = ltrim( str_replace($replacer->getMcloudBaseUrl(), '', $this->mcloudPostUrl), '/', ); $this->baseKey = ltrim( trailingslashit( str_replace( $this->post->getBasename(), '', $this->key ) ), '/' ); } public function getGeneralS3Info(): array { return $this->getS3Info($this->getMcloudPostUrl(), $this->getKey()); } public function getSizeS3Info(string $sizeFilename): array { return $this->getS3Info( $this->getMcloudPostBaseUrl() . $sizeFilename, $this->getBaseKey() . $sizeFilename ); } private function getS3Info(string $url, string $key): array { return [ 'url' => $url, 'bucket' => $this->replacer->getBucket(), 'provider' => 's3', 'privacy' => ReplacerService::S3_ACL, 'v' => MEDIA_CLOUD_INFO_VERSION, 'key' => $key, 'options' => [], 'mime-type' => $this->post->getPostMimeType(), ]; } public function getMcloudPostUrl(): string { return $this->mcloudPostUrl; } public function getMcloudPostBaseUrl(): string { return $this->mcloudPostBaseUrl; } public function getLocalPostBaseUrl(): string { return $this->localPostBaseUrl; } public function getKey(): string { return $this->key; } public function getBaseKey(): string { return $this->baseKey; } }