kuvalda-file/console/MoveController.php

49 lines
964 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @link https://www.kuvalda.ru/
* @copyright
* @license
*/
namespace dominion\file\console;
use Yii;
use yii\console\Controller;
use yii\console\ExitCode;
use dominion\file\File;
/**
* залить файлы с диска на s3
*
* @author Rybkin Sasha <ribkin@dominion.ru>
* @since 0.1
*/
class MoveController extends Controller
{
/**
* переносим данные с диска в s3
* @return int Exit code
*/
public function actionIndex()
{
$flag = true;
$limit = 100;
$offset = 0;
while ($flag)
{
$models = File::find()->limit($limit)->offset($offset)->all();
foreach ($models as $model)
{
$model->moveToS3(false);
}
$flag = count($models) == $limit;
$offset += $limit;
echo "перенесено: {$offset} \n";
}
return ExitCode::OK;
}
}