Skip to content

Commit

Permalink
refactor: 分片上传文件仅返回路径
Browse files Browse the repository at this point in the history
  • Loading branch information
slowlyo committed Jul 20, 2024
1 parent 16b43e7 commit c991c25
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Traits/UploadTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,13 @@ public function chunkUploadFinish()
$fileName = request('filename');
$partList = request('partList');
$uploadId = request('uploadId');
$type = request('t');
$type = request('t', 'uploads');

$ext = pathinfo($fileName, PATHINFO_EXTENSION);
$path = $type . '/' . $uploadId . '.' . $ext;
$fullPath = storage_path('app/public/' . $path);

$dir = dirname($fullPath);
if (!is_dir($dir)) {
app('filesystem')->makeDirectory($dir);
}
make_dir(dirname($fullPath));

for ($i = 0; $i < count($partList); $i++) {
$partNumber = $partList[$i]['partNumber'];
Expand All @@ -148,10 +145,8 @@ public function chunkUploadFinish()

clearstatcache();

$value = admin_resource_full_path($path);

app('files')->deleteDirectory(storage_path('app/public/chunk/' . $uploadId));

return $this->response()->success(['value' => $value], '上传成功');
return $this->response()->success(['value' => $path], '上传成功');
}
}

0 comments on commit c991c25

Please sign in to comment.