Skip to content

Commit

Permalink
Delete attachment's file on disk
Browse files Browse the repository at this point in the history
  • Loading branch information
burakcakirel committed Jun 17, 2021
1 parent 873d25c commit 9dd1c92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/Http/Controllers/Common/Uploads.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public function get($id)
}

// Get file path
if (!$path = $this->getMediaPathOnStorage($media)) {
if (!$this->getMediaPathOnStorage($media)) {
return response(null, 204);
}

return $this->streamMedia($media, $path);
return $this->streamMedia($media);
}

/**
Expand Down Expand Up @@ -70,7 +70,7 @@ public function show($id, Request $request)
}

// Get file path
if (!$path = $this->getMediaPathOnStorage($media)) {
if (!$this->getMediaPathOnStorage($media)) {
return response()->json([
'success' => false,
'error' => true,
Expand Down Expand Up @@ -108,11 +108,11 @@ public function download($id)
}

// Get file path
if (!$path = $this->getMediaPathOnStorage($media)) {
if (!$this->getMediaPathOnStorage($media)) {
return false;
}

return $this->streamMedia($media, $path);
return $this->streamMedia($media);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/Traits/Uploads.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public function getMediaPathOnStorage($media)
return false;
}

return Storage::path($path);
return $path;
}

public function streamMedia($media, $path = '')
public function streamMedia($media)
{
return response()->streamDownload(
function() use ($media) {
Expand Down

0 comments on commit 9dd1c92

Please sign in to comment.