File assets should always give IO::File::WithPath objects to PSGI, instead of the current redirecting or streaming behavior. (#11688)

New API method:  WebGUI::Response::sendFile;  it, as appropriate, calls
setRedirect or setStreamedFile, depending on enableStreamingUploads config var.
setStreamedFile now kicks off the XSendfile process.
File.pm now uses this instead of trying to set both a redirect and a stream.
IO::File::WithPath blows up if a file doesn't exist so this raises an exception
now.
The http now no longer insist that '0' is not a valid filename to stream.
site.psgi, depending on enableStreamingUploads, enables either the Static
or XSendfile middleware.
This commit is contained in:
Scott Walters 2011-05-12 20:09:04 -04:00
parent 96bb194402
commit 7a994b59ce
6 changed files with 184 additions and 25 deletions

View file

@ -619,9 +619,10 @@ sub www_view {
return sprintf($i18n->get("file not found"), $self->getUrl());
}
$session->response->setRedirect($self->getFileUrl) unless $session->config->get('enableStreamingUploads');
$session->response->setStreamedFile($self->getStorageLocation->getPath($self->filename));
$session->response->sendHeader;
# sendFile does either a redirect or starts a stream depending on how we're configured
$session->response->sendFile($self->getStorageLocation, $self->filename);
return 'chunked';
}