Make File assets work with the exporter. This means not using the streaming
mechanism. This isn't optimal; should find a way to use the streaming mechanism iff we know that there's going to be a live HTTP session on the other end and not just a filehandle.
This commit is contained in:
parent
dc5d96dd5b
commit
d0bacc8988
2 changed files with 29 additions and 17 deletions
|
|
@ -20,6 +20,7 @@ use WebGUI::Cache;
|
|||
use WebGUI::Storage;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use FileHandle;
|
||||
|
||||
our @ISA = qw(WebGUI::Asset);
|
||||
|
||||
|
|
@ -371,14 +372,26 @@ sub www_edit {
|
|||
sub www_view {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
if ($self->session->var->get("adminOn")) {
|
||||
return $self->getContainer->www_view;
|
||||
# if ($self->session->var->get("adminOn")) {
|
||||
# return $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 "";
|
||||
binmode $fh or ($fh->close, return "");
|
||||
my $block;
|
||||
while (read($fh, $block, 16384) > 0) {
|
||||
$self->session->output->print($block, 1);
|
||||
}
|
||||
$self->session->http->setRedirect($self->getFileUrl);
|
||||
$self->session->http->setStreamedFile($self->getStorageLocation->getPath($self->get("filename")));
|
||||
return '1';
|
||||
$fh->close;
|
||||
return 'chunked';
|
||||
|
||||
# $self->session->http->setRedirect($self->getFileUrl);
|
||||
# $self->session->http->setStreamedFile($self->getStorageLocation->getPath($self->get("filename")));
|
||||
# return '1';
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue