Skip to content

Commit

Permalink
Fix file download
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdekruijk authored Jan 25, 2022
1 parent 11932f4 commit 8cc054f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Controllers/ModelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ public function download($slug, $id, $column, $data)
$this->checkSlug($slug, 'read');
$row = @$this->model()::findOrFail($id, $this->filter_pivot($this->columns()))->getOriginal();
abort_if(empty($row[$column]), 404);
$array = json_decode($row[$column]);
abort_if(empty($array->$data) || !isset($array->$data->name) || !isset($array->$data->type) || !isset($array->$data->size) || !isset($array->$data->store), 404);
$file = rtrim($this->columns('data')['storage_path'] ?? storage_path(), '/') . '/' . $array->$data->store;
abort_if(!file_exists($file), 404);
return response()->download($file, $array->$data->name);
$file = (object)$row[$column][$data];
abort_if(empty($file) || !isset($file->name) || !isset($file->type) || !isset($file->size) || !isset($file->store), 404);
$file_path = rtrim($this->columns('data')['storage_path'] ?? storage_path(), '/') . '/' . $file->store;
abort_if(!file_exists($file_path), 404);
return response()->download($file_path, $file->name);
}

/**
Expand Down

0 comments on commit 8cc054f

Please sign in to comment.