On 6 Nov 2008, at 16:04, Dr. Jennifer Nussbaum wrote:
Theres a length difference when i download. A test file i uploaded is 165681 bytes, but when i upload and save it to the database, and then display the file from my app and save it, its 165685 bytes-- four more.

What should i be looking at to try to figure this out?

Break the problem down into smaller pieces. I have two lines of attack to offer:

What are the first few, and the last few bytes of the input and output files?

I'd be prepared to bet that you're appending 4 bytes somewhere, either at the start, or the end of the document.. So have a look, and tell us which?

Then start adding some debug, so your code becomes:

my $upload = $c->request->upload('document');
my $contents = $upload->slurp;
$c->log->debug("Uploaded file was " . length($contents) . " bytes");
my $document = $c->model->create({ document => $contents,
                                   type => $upload->type,
                                   filename => $upload->basename});

and

my $contents = $document->document;
$c->log->debug("Document contents were " . length($contents) . " bytes");
$c->res->output($contents);
$c->res->headers->content_type($document->type);

Which should tell you which end (input or output) you're gaining your bytes at...

Cheers
t0m


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to