123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use App\Models\ImportPost;
- use App\Jobs\ImportPipeline\ImportMediaToCloudPipeline;
- use function Laravel\Prompts\progress;
- class ImportUploadMediaToCloudStorage extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'app:import-upload-media-to-cloud-storage {--limit=500}';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Migrate media imported from Instagram to S3 cloud storage.';
- /**
- * Execute the console command.
- */
- public function handle()
- {
- if(
- (bool) config('import.instagram.storage.cloud.enabled') === false ||
- (bool) config_cache('pixelfed.cloud_storage') === false
- ) {
- $this->error('Aborted. Cloud storage is not enabled for IG imports.');
- return;
- }
- $limit = $this->option('limit');
- $progress = progress(label: 'Migrating import media', steps: $limit);
- $progress->start();
- $posts = ImportPost::whereUploadedToS3(false)->take($limit)->get();
- foreach($posts as $post) {
- ImportMediaToCloudPipeline::dispatch($post)->onQueue('low');
- $progress->advance();
- }
- $progress->finish();
- }
- }
|