Skip to content
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

Fix HTTP headers when downloading files #2031

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/Http/Controllers/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use PDO;

require_once 'include/repository.php';
Expand Down Expand Up @@ -846,7 +846,7 @@ public function files(int $build_id): View
->with('urls', $urls);
}

public function build_file(int $build_id, int $file_id) : StreamedResponse
public function build_file(int $build_id, int $file_id): BinaryFileResponse
{
$this->setBuildById($build_id);

Expand All @@ -858,7 +858,10 @@ public function build_file(int $build_id, int $file_id) : StreamedResponse
$uploadFile = new UploadFile();
$uploadFile->Id = $file_id;
$uploadFile->Fill();
return Storage::download("upload/{$uploadFile->Sha1Sum}", $uploadFile->Filename);
return response()->file(Storage::path("upload/{$uploadFile->Sha1Sum}"), [
"Content-Type" => "text/plain",
"Content-Disposition" => "inline/attachment; filename={$uploadFile->Filename}",
]);
}

public function ajaxBuildNote(): View
Expand Down