-
Notifications
You must be signed in to change notification settings - Fork 16
Fix upstream #14 image deletion #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,17 +27,22 @@ public function upload(Request $request) | |
|
|
||
| $data[] = [ | ||
| 'image' => $savedImage, | ||
| 'saved_path' => $savedImage, | ||
| 'url' => Storage::disk($disk)->url($savedImage), | ||
| ]; | ||
| } | ||
|
|
||
| return $data; | ||
| } | ||
|
|
||
| public function delete($image) | ||
| public function delete(Request $request, $saved_path) | ||
| { | ||
| Storage::delete($image); | ||
| $disk = $request->disk ? $request->disk : 'local'; | ||
|
|
||
| $deleted = Storage::disk($disk)->delete($saved_path); | ||
|
|
||
| return "success"; | ||
| return $deleted === true | ||
| ? 'success' | ||
| : response('not deleted', 404); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be better like that ? return $deleted === true
? response()->noContent()
: response('Files not found.', 404);
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if this should be really a RESTful controller, but this works so I don't know about no use. I haven't time to start a new package handling all these issues at once, and was expecting the original writer could attend to the PR's but I'll keep in mind your observation and think the handling of the images in a more restful way. |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not
console.error?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is not an error in the frontend, and indeed this is not the best way to handle the error, actually it should show a toast or mark the file in some way to let the user know that maybe communication with the backend was temporarily not possible (timed-out), the file could not be found, the path was wrong, etc.