cURL / Mailing Lists / curl-users / Single Mail

curl-users

curl (win32) fails to upload binary data from stdin

From: Jan Dostrasil via curl-users <curl-users_at_cool.haxx.se>
Date: Thu, 04 Jun 2015 00:21:26 +0200 (CEST)

Hello, I'm trying to pipe encrypted backup to curl and upload it to a server,
but it does not work.

First I tried this:
tar -cvf- mydir|gpg --passphrase mypass -c -o-|curl -F
"filetoupload=@-;filename=mydir.tar.gpg" --url http://myserver/upload.php
This resulted in a broken pipe reported by gpg. The first first few bytes were
 ok on the server, then came some garbage and file was much smaller.

Second try was this:
tar -cvf- mydir|gpg --passphrase mypass -c -o->mydir.tar.gpg
curl -F "filetoupload=@-;filename=mydir.tar.gpg" --url
http://myserver/upload.php<mydir.tar.gpg
This uploaded bigger part of the file, first few bytes were ok, but only up
to the character 0x1a. Upload was corrupted again.

With the last try I dumped the gpg data as a base64 and everything worked fine
 (required 33% bigger upload because of base 64):
tar -cvf- mydir|gpg --passphrase mypass -ca -o-|curl -F
"filetoupload=@-;filename=mydir.tar.gpg" --url http://myserver/upload.php

It look like curl is expecting data on a pipe as a plain text only. Does it
work on linux? This seems like as a bug to me. I'd like to encrypt and upload
on the fly via pipe, which is way faster and I don't need twice the space for
a temporary file.

I'm working on windows and using latest win32 generic binary from Dirk Peahl
(curl 7.42.1 (i386-pc-win32) libcurl/7.42.1 OpenSSL/1.0.2a zlib/1.2.8)

Thank you for help.

With kind regards Jan Dostrasil
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-06-04