cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Question on sending gzip file via HTTPS

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 4 Jun 2007 12:44:08 -0700

On Mon, Jun 04, 2007 at 03:30:41PM -0400, Woody.R.Gingery_at_dom.com wrote:
> In an earlier question on the same topic I had asked about how to specify
> that a file being sent from our server to a client server is a binary file.
> Based on the response, I added "type=application/octet-stream" to the file
> name that is to be created at the receiving end. I also used the "verbose"
> option on the curl command.

Use the --trace-ascii option instead to better see what data is sent by
which end.

> The gzipp'ed file did transfer but cannot be unzipped at the receiving end,
> Winzip responds with an "Invalid archive directory" message. When I look at
> the output log from our Perl/Curl script, with verbose I see a message that
> says "Content-type: text/html". I'm assuming the file is still being
> treated as a text file on the receiving end. Do both ends of the
> transmission need to specify type=application/octet-stream for the binary
> file?

You're seeing the Content-type of the remote server's response to your
POST, which is an HTML message.

> $document_name = "xxxxxxxxxx$parm_month$parm_year.txt.gz;type=application
> /octet-stream";
> print "document being transferred is: $document_name\n";
> $https = "
> https:\/\/www.xxxx.xxxx.xx.us\/WebFX\/MainMenu\/Uploads\/UploadAFile\
> /index.cfm?fuseaction=loginandinsertdocumentrecord";
> # setup the system call to curl, passing the appropriate flags
> # --fail suppress output so it dies nicely
> # --output says to direct the output to the file named in $ARGV[3]
> # $http_string is where the file name and https address are stored
> @args = ("curl", '--fail', '-v', '-F', 'username=yyyyyyy', '-F',
> 'password=xxxx', '-F', 'documentname='.$document_name, '-F',
> 'expirationdate='.$expire_dat
> e, '-F', 'Filecontents=@'.$source_file, '-F', "pbADD='Add new document
> informati
> on'", $https);

However, this doesn't look right. The ;type= suffix needs to be on the
actual data file parameter, i.e. "Filecontents" in this case, not on
the file name parameter "documentname", otherwise curl will use its
default content-type handling on the actual file contents (which is
probably text/plain).

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-06-04