diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 15b567de2..5e1c7e7b4 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -5,6 +5,7 @@ ldapAlias config setting and it crash (Martin Kamerbeek / Procolix) - fix: entry in error log of WebGUI - Fixed part of RSSCapable addition upgrade script in 7.2.0. + - fix: MIME types broken from change to the way File assets were streamed 7.2.0 - Added server side spellchecker (Martin Kamerbeek / Procolix) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index b0e447bf6..d8dfad29c 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2133,5 +2133,20 @@ true. sub isValidRssItem { 1 } +#------------------------------------------------------------------- + +=head2 exportHtml_view ( ) + +View method for static export. This is like www_view, and defaults to +just calling www_view, but this needs to be overridden if www_view +depends on there being an actual HTTP response on the other end. + +=cut + +sub exportHtml_view { + my $self = shift; + $self->www_view(@_); +} + 1; diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index fbff18d66..24bb10364 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -369,14 +369,16 @@ sub www_edit { } #------------------------------------------------------------------- -sub www_view { + +# setStreamedFile and setRedirect do not interact well with the +# exporter. We have a separate method for this now. +sub exportHtml_view { my $self = shift; return $self->session->privilege->noAccess() unless $self->canView; # if ($self->session->var->get("adminOn")) { # return $self->session->asset($self->getContainer)->www_view; # } - # Kludge for now to make this work with the exporter. my $path = $self->getStorageLocation->getPath($self->get('filename')); my $fh = eval { FileHandle->new($path) }; defined($fh) or return ""; @@ -387,10 +389,15 @@ sub www_view { } $fh->close; return 'chunked'; +} -# $self->session->http->setRedirect($self->getFileUrl); -# $self->session->http->setStreamedFile($self->getStorageLocation->getPath($self->get("filename"))); -# return '1'; +sub www_view { + my $self = shift; + return $self->session->privilege->noAccess() unless $self->canView; + + $self->session->http->setRedirect($self->getFileUrl); + $self->session->http->setStreamedFile($self->getStorageLocation->getPath($self->get("filename"))); + return 'chunked'; } diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index de5ff5c16..b8b084305 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -156,7 +156,7 @@ sub _exportAsHtml { } else { $assetSession->output->setHandle($file); $assetSession->asset($asset); - my $content = $asset->www_view; + my $content = $asset->exportHtml_view; unless ($content eq "chunked") { $assetSession->output->print($content); }