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