Solstice::View::Resource::File::Upload - Solstice::View::Resource::File::Upload documentation


Solstice documentation Contained in the Solstice distribution.

Index


Code Index:

NAME

Top

Solstice::View::Resource::File::Upload -

SYNOPSIS

Top

  # See L<Solstice::View> for usage.

DESCRIPTION

Top

This uploads a file, and then prints out a little page that has the encrypted file id. This is part of the upload system; the output is designed to be consumed by javascript.

Export

None by default.

Methods

printData()
sendHeaders()

AUTHOR

Top

Catalyst Research & Development Group, <catalyst@u.washington.edu>

VERSION

Top

$Revision: $

SEE ALSO

Top

Solstice::View::Download, perl.

COPYRIGHT

Top


Solstice documentation Contained in the Solstice distribution.
package Solstice::View::Resource::File::Upload;

# $Id: $

use strict;
use warnings;
use 5.006_000;

use base qw(Solstice::View::Download);

use Solstice::Encryption;
use Solstice::Server;
use Solstice::StringLibrary qw(truncstr);

use constant TRUE  => 1;
use constant FALSE => 0;

our ($VERSION) = ('$Revision: $' =~ /^\$Revision:\s*([\d.]*)/);

sub printData {
    my $self = shift;
    
    my $file = $self->getModel();
    
    if (defined $file && $file->getID()) {
        my $encryption = Solstice::Encryption->new();
        my $enc_id = $encryption->encrypt('file_'.$file->getID());
    
        my $type = $file->getContentType();
        my $filename = truncstr($file->getName(), 35);
    
        print '<html><body>'.
            '<input type="hidden" id="file_key" value="'.$enc_id.'"/>'.
            '<input type="hidden" id="file_url" value="'.$file->getTicketURL().'"/>'.
            '<input type="hidden" id="file_size" value="'.$file->getSize().'"/>'.
            '<input type="hidden" id="file_name" value="'.$filename.'"/>'.
            '<input type="hidden" id="file_desc" value="'.$self->getContentTypeService()->getContentDescriptionByContentType($type).'"/>'.
            '<input type="hidden" id="file_icon" value="'.$self->getIconService()->getIconByType($type).'"/>'.
            '</body></html>';
    } else {
        print '<html><body><input type="hidden" id="file_error" value="Error"/></body></html>';
    }
}

sub sendHeaders {
    my $self = shift;
    Solstice::Server->new()->setContentType('text/html');
}


1;
__END__