Do not set a redirect when streaming downloads. fixes file #11029
This commit is contained in:
parent
564378bba8
commit
77fc01af38
3 changed files with 26 additions and 17 deletions
|
|
@ -5,6 +5,7 @@
|
|||
- fixed #11027: trash warning but no trash-limbo warning
|
||||
- fixed #11031: AssetProxy refering to trash-limbo asset
|
||||
- fixed #11028: IOB: Not choosing status causes Problem With Request
|
||||
- fixed #11029: enableStreamingUploads
|
||||
|
||||
7.8.0
|
||||
- upgraded YUI to 2.8.0r4
|
||||
|
|
|
|||
|
|
@ -656,19 +656,20 @@ When viewed directly, stream the stored file to the user.
|
|||
=cut
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->noAccess() unless $self->canView;
|
||||
|
||||
# Check to make sure it's not in the trash or some other weird place
|
||||
if ($self->get("state") ne "published") {
|
||||
my $i18n = WebGUI::International->new($self->session,'Asset_File');
|
||||
$self->session->http->setStatus("404");
|
||||
my $i18n = WebGUI::International->new($session,'Asset_File');
|
||||
$session->http->setStatus("404");
|
||||
return sprintf($i18n->get("file not found"), $self->getUrl());
|
||||
}
|
||||
|
||||
$self->session->http->setRedirect($self->getFileUrl);
|
||||
$self->session->http->setStreamedFile($self->getStorageLocation->getPath($self->get("filename")));
|
||||
$self->session->http->sendHeader;
|
||||
$session->http->setRedirect($self->getFileUrl) unless $session->config->get('enableStreamingUploads');
|
||||
$session->http->setStreamedFile($self->getStorageLocation->getPath($self->get("filename")));
|
||||
$session->http->sendHeader;
|
||||
return 'chunked';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use WebGUI::Asset::File;
|
|||
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
plan tests => 8;
|
||||
plan tests => 10;
|
||||
|
||||
#TODO: This script tests certain aspects of WebGUI::Storage and it should not
|
||||
|
||||
|
|
@ -32,7 +32,6 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
##Create a storage location
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
|
||||
##Save the image to the location
|
||||
my $filename = "someScalarFile.txt";
|
||||
|
|
@ -48,6 +47,7 @@ cmp_bag($storage->getFiles, ['someScalarFile.txt'], 'Only 1 file in storage with
|
|||
$session->user({userId=>3});
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"File Asset test"});
|
||||
my $guard1 = cleanupGuard($versionTag);
|
||||
my $properties = {
|
||||
# '1234567890123456789012'
|
||||
id => 'FileAssetTest000000012',
|
||||
|
|
@ -85,15 +85,22 @@ $versionTag->commit;
|
|||
############################################
|
||||
|
||||
my $fileStorage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($fileStorage);
|
||||
my $guard2 = cleanupGuard($fileStorage);
|
||||
$mocker->set_always('getValue', $fileStorage->getId);
|
||||
my $fileFormStorage = $asset->getStorageFromPost();
|
||||
isa_ok($fileFormStorage, 'WebGUI::Storage', 'Asset::File::getStorageFromPost');
|
||||
|
||||
END {
|
||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
##Storage is cleaned up by rolling back the version tag
|
||||
$fileStorage->delete;
|
||||
}
|
||||
############################################
|
||||
#
|
||||
# www_view
|
||||
#
|
||||
############################################
|
||||
|
||||
$session->config->set('enableStreamingUploads', '0');
|
||||
$asset->www_view;
|
||||
is($session->http->getRedirectLocation, $storage->getUrl('someScalarFile.txt'), 'www_view: sets a redirect');
|
||||
|
||||
$session->config->set('enableStreamingUploads', '1');
|
||||
$session->http->setRedirectLocation('');
|
||||
$asset->www_view;
|
||||
is($session->http->getRedirectLocation, '', '... redirect not set when enableStreamingUploads is set');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue