diff --git a/app/Services/Media/PathGenerator.php b/app/Services/Media/PathGenerator.php new file mode 100644 index 00000000..4af528cd --- /dev/null +++ b/app/Services/Media/PathGenerator.php @@ -0,0 +1,35 @@ +id).'/'; + } + + /* + * Get the path for conversions of the given media, relative to the root storage path. + */ + public function getPathForConversions(Media $media): string + { + return $this->getPath($media).'conversions/'; + } + + /* + * Get the path for responsive images of the given media, relative to the root storage path. + */ + public function getPathForResponsiveImages(Media $media): string + { + return $this->getPath($media).'responsive-images/'; + } + +} diff --git a/app/Services/Media/Resources/MediaResource.php b/app/Services/Media/Resources/MediaResource.php index 467dc332..3ae0324c 100644 --- a/app/Services/Media/Resources/MediaResource.php +++ b/app/Services/Media/Resources/MediaResource.php @@ -2,6 +2,7 @@ namespace App\Services\Media\Resources; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class MediaResource extends JsonResource @@ -9,7 +10,7 @@ class MediaResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param Request $request * @return array */ public function toArray($request) diff --git a/app/Services/Media/UrlGenerator/FtpUrlGenerator.php b/app/Services/Media/UrlGenerator/FtpUrlGenerator.php new file mode 100644 index 00000000..74b8c48f --- /dev/null +++ b/app/Services/Media/UrlGenerator/FtpUrlGenerator.php @@ -0,0 +1,55 @@ +getPathRelativeToRoot(); + } + + /** + * @param \DateTimeInterface $expiration + * @param array $options + * + * @return string + * + * @throws UrlCannotBeDetermined + */ + public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string + { + throw UrlCannotBeDetermined::filesystemDoesNotSupportTemporaryUrls(); + return 'done'; + } + + /** + * Get the relative path for the profile of a media item. + * + * @return string + * + */ + public function getPath() + { + return $this->getPathRelativeToRoot(); + } + + /** + * Get the url to the directory containing responsive images. + * + * @return string + */ + public function getResponsiveImagesDirectoryUrl(): string + { + return config('media-library.wm-cdn').'/'.$this->pathGenerator->getPathForResponsiveImages($this->media); + } +} diff --git a/app/Services/Media/UrlGenerator/S3UrlGenerator.php b/app/Services/Media/UrlGenerator/S3UrlGenerator.php new file mode 100644 index 00000000..478bcb60 --- /dev/null +++ b/app/Services/Media/UrlGenerator/S3UrlGenerator.php @@ -0,0 +1,54 @@ +getPathRelativeToRoot(); + } + + /** + * @param \DateTimeInterface $expiration + * @param array $options + * + * @return string + * + */ + public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string + { + + return 'done'; + } + + /** + * Get the relative path for the profile of a media item. + * + * @return string + * + */ + public function getPath(): string + { + return $this->getPathRelativeToRoot(); + } + + /** + * Get the url to the directory containing responsive images. + * + * @return string + */ + public function getResponsiveImagesDirectoryUrl(): string + { + return config('media-library.s3.domain').'/'.$this->pathGenerator->getPathForResponsiveImages($this->media); + } +} diff --git a/composer.lock b/composer.lock index f4fe2449..18cebfe0 100644 --- a/composer.lock +++ b/composer.lock @@ -62,16 +62,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.293.5", + "version": "3.293.7", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "f2002e52b382b45231da3f9552033f769acfebd8" + "reference": "3bf86ba8b9bbea2b298f89e6f5edc58de276690b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/f2002e52b382b45231da3f9552033f769acfebd8", - "reference": "f2002e52b382b45231da3f9552033f769acfebd8", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3bf86ba8b9bbea2b298f89e6f5edc58de276690b", + "reference": "3bf86ba8b9bbea2b298f89e6f5edc58de276690b", "shasum": "" }, "require": { @@ -151,9 +151,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.293.5" + "source": "https://github.com/aws/aws-sdk-php/tree/3.293.7" }, - "time": "2023-12-06T19:09:15+00:00" + "time": "2023-12-08T19:11:21+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -7614,23 +7614,23 @@ }, { "name": "tijsverkoyen/css-to-inline-styles", - "version": "2.2.6", + "version": "v2.2.7", "source": { "type": "git", "url": "https://github.com/tijsverkoyen/CssToInlineStyles.git", - "reference": "c42125b83a4fa63b187fdf29f9c93cb7733da30c" + "reference": "83ee6f38df0a63106a9e4536e3060458b74ccedb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/c42125b83a4fa63b187fdf29f9c93cb7733da30c", - "reference": "c42125b83a4fa63b187fdf29f9c93cb7733da30c", + "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/83ee6f38df0a63106a9e4536e3060458b74ccedb", + "reference": "83ee6f38df0a63106a9e4536e3060458b74ccedb", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "php": "^5.5 || ^7.0 || ^8.0", - "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0" + "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10" @@ -7661,9 +7661,9 @@ "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", "support": { "issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues", - "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.6" + "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/v2.2.7" }, - "time": "2023-01-03T09:29:04+00:00" + "time": "2023-12-08T13:03:43+00:00" }, { "name": "vlucas/phpdotenv", @@ -8655,29 +8655,29 @@ }, { "name": "phpspec/prophecy", - "version": "v1.17.0", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2" + "reference": "d4f454f7e1193933f04e6500de3e79191648ed0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/15873c65b207b07765dbc3c95d20fdf4a320cbe2", - "reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d4f454f7e1193933f04e6500de3e79191648ed0c", + "reference": "d4f454f7e1193933f04e6500de3e79191648ed0c", "shasum": "" }, "require": { "doctrine/instantiator": "^1.2 || ^2.0", - "php": "^7.2 || 8.0.* || 8.1.* || 8.2.*", + "php": "^7.2 || 8.0.* || 8.1.* || 8.2.* || 8.3.*", "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" + "sebastian/comparator": "^3.0 || ^4.0 || ^5.0", + "sebastian/recursion-context": "^3.0 || ^4.0 || ^5.0" }, "require-dev": { "phpspec/phpspec": "^6.0 || ^7.0", "phpstan/phpstan": "^1.9", - "phpunit/phpunit": "^8.0 || ^9.0" + "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0" }, "type": "library", "extra": { @@ -8710,6 +8710,7 @@ "keywords": [ "Double", "Dummy", + "dev", "fake", "mock", "spy", @@ -8717,9 +8718,9 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.17.0" + "source": "https://github.com/phpspec/prophecy/tree/v1.18.0" }, - "time": "2023-02-02T15:41:36+00:00" + "time": "2023-12-07T16:22:33+00:00" }, { "name": "phpstan/phpdoc-parser",