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,23 +85,27 @@ class OssCopy extends Command
{
$data = [];
foreach($attributes as $key) {
$item = $model->$key;
if (!$item) {
continue;
}
// 数组
if (is_array($item)) {
$values = [];
foreach($item as $value) {
array_push($values, $this->copy($value));
try {
$item = $model->$key;
if (!$item) {
continue;
}
$data[$key] = $values;
}
// 富文本
else if (preg_match('/^\<.+\>$/i', $item)) {
$data[$key] = $this->parseEditorImage($item);
} else {
$data[$key] = $this->copy($item);
// 数组
if (is_array($item)) {
$values = [];
foreach($item as $value) {
array_push($values, $this->copy($value));
}
$data[$key] = $values;
}
// 富文本
else if (preg_match('/^\<.+\>$/i', $item)) {
$data[$key] = $this->parseEditorImage($item);
} else {
$data[$key] = $this->copy($item);
}
} catch (OssException $e) {
$this->error('key: ' . $key . ', value: ' . $item . ', id: ' . $model->id);
}
}
if (count($data) > 0) {
@ -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);
}
$client->copyObject($oldBucket, $path, $bucket, $path);
return $newUrl . $path;
}