-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Stacked 2] Add Enum storage. (#2380)
* [Stacked 3] Add storage disk to Size Variants. (#2381) * [Stacked 4] Refactor deletion (#2382) * [Stacked 5] Remove local requirement Middleware (#2383) * [Stacked 6] Remove hard coded values from naming strategy (#2384) * [Stacked 7] Finally upload the data to S3 (#2385)
- Loading branch information
Showing
26 changed files
with
457 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Actions\Photo\Pipes\Shared; | ||
|
||
use App\Assets\Features; | ||
use App\Contracts\PhotoCreate\PhotoDTO; | ||
use App\Contracts\PhotoCreate\PhotoPipe; | ||
use App\Jobs\UploadSizeVariantToS3Job; | ||
use App\Models\Configs; | ||
use App\Models\SizeVariant; | ||
|
||
/** | ||
* Upload SizeVariants to S3 once done (if enabled). | ||
* Note that we first create the job, then we dispatch it. | ||
* This allows to manage the queue properly and see it in the feedback. | ||
*/ | ||
class UploadSizeVariantsToS3 implements PhotoPipe | ||
{ | ||
public function handle(PhotoDTO $state, \Closure $next): PhotoDTO | ||
{ | ||
if (Features::active('use-s3')) { | ||
$use_job_queues = Configs::getValueAsBool('use_job_queues'); | ||
|
||
$jobs = $state->getPhoto()->size_variants->toCollection() | ||
->filter(fn ($v) => $v !== null) | ||
->map(fn (SizeVariant $variant) => new UploadSizeVariantToS3Job($variant)); | ||
|
||
$jobs->each(fn ($job) => $use_job_queues ? dispatch($job) : dispatch_sync($job)); | ||
} | ||
|
||
return $next($state); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Enum; | ||
|
||
enum StorageDiskType: string | ||
{ | ||
case LOCAL = 'images'; | ||
case S3 = 's3'; | ||
} |
Oops, something went wrong.