I'm building a system that gives authorized users access to protected documents. These documents are served through the perl script upon request via https. This script requires a valid login before serving such documents.

This script works fine for all of my binary files except for one: .eps files. Once the file is downloaded from a browser, graphic editing programs, such as photoshop, returning parsing errors. However, if I have the same script simply dump the data to a file on the server and then FTP the file to my computer, it works just fine. Obviously, there is an issue related to Apache's handling of the .eps data that is different than the other binary files.

Here is a simplified version of the script:


#!/usr/bin/perl -w use strict; my $dir = "/home/sitedirectory/document_repository/"; my $file = "company_logo.eps"; my $mimetype = "application/postscript"; open(FILE,"$dir$file"); binmode(FILE, ':raw'); my $output; my $buffer; while (read(FILE,$buffer,1024)) { $output .= $buffer; } my $length = length($output); print qq{Content-Disposition:attachment; filename="$file"\n\n}; print "Content-type: $mimetype\n\n"; print qq{Content-Length: $length\n\n}; print $output; exit;


Any help on this would be greatly appreciated!

In reply to Print .eps files via https by Jkltng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.