6
0
Fork 0

OssCopyCommand

base
panliang 2022-07-29 15:11:11 +08:00
parent 000b13a075
commit 865b36bcd6
1 changed files with 21 additions and 21 deletions

View File

@ -85,6 +85,7 @@ class OssCopy extends Command
{
$data = [];
foreach($attributes as $key) {
try {
$item = $model->$key;
if (!$item) {
continue;
@ -103,6 +104,9 @@ class OssCopy extends Command
} else {
$data[$key] = $this->copy($item);
}
} catch (OssException $e) {
$this->error('key: ' . $key . ', value: ' . $item . ', id: ' . $model->id);
}
}
if (count($data) > 0) {
$model->forceFill($data)->save();
@ -120,11 +124,7 @@ class OssCopy extends Command
if (Str::startsWith($url, $baseUrl)) {
$path = substr($url, strlen($baseUrl));
$bucket = 'jiqu-library';
try {
$client->copyObject($oldBucket, $path, $bucket, $path);
} catch (OssException $e) {
$this->error('地址:' . $url);
}
return $newUrl . $path;
}