Skip to content

Commit

Permalink
Implement copy file
Browse files Browse the repository at this point in the history
  • Loading branch information
flowan committed Feb 1, 2024
1 parent 69da5e1 commit c9a82a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/Http/Controllers/Api/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,21 @@ public function move(Request $request): JsonResponse
'moved' => Storage::move($source, $destination),
]);
}

public function copy(Request $request): JsonResponse
{
$source = bucket_relative_path(
$request->input('bucket'),
$request->input('source')
);

$destination = bucket_relative_path(
$request->input('bucket'),
$request->input('destination')
);

return response()->json([
'copied' => Storage::copy($source, $destination),
]);
}
}
1 change: 1 addition & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Route::post('file/meta', [FileController::class, 'meta']);
Route::post('file/exists', [FileController::class, 'exists']);
Route::post('file/move', [FileController::class, 'move']);
Route::post('file/copy', [FileController::class, 'copy']);
Route::delete('file', [FileController::class, 'destroy']);

Route::post('directory', [DirectoryController::class, 'store']);
Expand Down

0 comments on commit c9a82a8

Please sign in to comment.