cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: base64-encoded image as form variable

From: Fedcba098 <fedcba098_at_gmail.com>
Date: Wed, 09 Oct 2013 19:56:41 -0700

Sorry, what do you mean by "why not just post the text?" What command
would I type to do this, and how would it differ from this?

|curl \|

| -F 'source=/9j/4AAQSkZJRgABAQEAAQABAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wgALCAABAAEBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAAAF//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABBQJ//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAGPwJ//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPyF//9oACAEBAAAAEH//xAAUEAEAAAAAAAAAAAAAAAAAAAAA/9oACAEBAAE/EH//2Q==' \|

| -F 'message=this message has a very small image of a single grey pixel attached to it in jpeg format' \|

| -F 'access_token=<secret>' \|

| https://graph.facebook.com/<user_id>/photos
|

Thanks

On 09/27/2013 07:14 AM, Bill Mercer wrote:
>
> Since it's base64 encoded, why not just post the text?
>
>
>
>
>
> *From:*curl-users [mailto:curl-users-bounces_at_cool.haxx.se] *On Behalf
> Of *Fedcba098
> *Sent:* Tuesday, September 24, 2013 10:52 PM
> *To:* curl-users_at_cool.haxx.se
> *Subject:* base64-encoded image as form variable
>
>
>
> I'm writing a script that extracts images from email and uploads them
> to facebook. As a result, I'm getting image data encoded in base64,
> and I'd like to upload this data using curl without saving the image
> data to a file on disk.
>
> Here is the body of my email:
>
> |Content-Type: multipart/mixed;|
> | boundary="------------030703050303060607000103"|
> | |
> |This is a multi-part message in MIME format.|
> |--------------030703050303060607000103|
> |Content-Type: text/plain; charset=ISO-8859-1|
> |Content-Transfer-Encoding: quoted-printable|
> | |
> |this message has a very small image of a single grey pixel attached to|
> |it in jpeg format|
> | |
> |--------------030703050303060607000103|
> |Content-Type: image/jpeg;|
> | name="grey.jpg"|
> |Content-Transfer-Encoding: base64|
> |Content-Disposition: attachment;|
> | filename="grey.jpg"|
> | |
> |/9j/4AAQSkZJRgABAQEAAQABAAD/2wBDAP//////////////////////////////////////|
> |////////////////////////////////////////////////wgALCAABAAEBAREA/8QAFAAB|
> |AAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAAAF//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgB|
> |AQABBQJ//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAGPwJ//8QAFBABAAAAAAAAAAAA|
> |AAAAAAAAAP/aAAgBAQABPyF//9oACAEBAAAAEH//xAAUEAEAAAAAAAAAAAAAAAAAAAAA/9oA|
> |CAEBAAE/EH//2Q==|
> |--------------030703050303060607000103--|
>
> The following command works, but would require me to save the data to
> a file on disk (which I'm trying to avoid)
>
> |curl \|
> | -F 'source=@pixel.jpg <mailto:source=@pixel.jpg>' \|
> | -F 'message=this message has a very small image of a single grey pixel attached to it in jpeg format' \|
> | -F 'access_token=<secret>' \|
> | https://graph.facebook.com/<user_id>/photos|
>
> The following command does not work, but it's essentially what I want
>
> |curl \|
> | -F 'source=/9j/4AAQSkZJRgABAQEAAQABAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wgALCAABAAEBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAAAF//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABBQJ//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAGPwJ//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPyF//9oACAEBAAAAEH//xAAUEAEAAAAAAAAAAAAAAAAAAAAA/9oACAEBAAE/EH//2Q==' \|
> | -F 'message=this message has a very small image of a single grey pixel attached to it in jpeg format' \|
> | -F 'access_token=<secret>' \|
> | https://graph.facebook.com/<user_id>/photos|
>
> Obviously, the above command will not work. For one, I didn't specify
> the encoding of the data as base64. Is it possible to specify the
> encoding for just a single field or would I have to do it for the
> whole message (requiring me to encode the |message| and |access_token|
> fields as base64 too)?
>
> In general, please tell me how to send a (base64 encoded) image via
> curl without first saving the data to a file on disk.
>
> TIA
>
>
>
> -------------------------------------------------------------------
> 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

-------------------------------------------------------------------
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 2013-10-10