chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] curl egg


From: Sven Hartrumpf
Subject: Re: [Chicken-users] curl egg
Date: Mon, 03 Aug 2015 14:46:53 +0200 (CEST)

Peter Bex <address@hidden> schrieb am Mon, 3 Aug 2015 10:15:57 +0200:
> On Mon, Aug 03, 2015 at 10:00:28AM +0200, Sven Hartrumpf wrote:
>> Hi all.
>> 
>> Chicken 3 had a curl egg.
>> It is linked in the page http://wiki.call-cc.org/eggref/3/index
>> as http://wiki.call-cc.org/eggref/3/curl , but
>> the latter page is missing.
> 
> Hello, Sven!
> 
> It looks like the documentation was never ported to the wiki,
> for some unknown reason.  Luckily, the eggdoc version is still
> available here (and in the svn repo as well):
> http://code.call-cc.org/legacy-eggs/3/curl.html
> 
>> Where is this old egg?
>> Any ideas what must be done to port it to Chicken 4?
> 
> The egg is still available from the chicken-eggs subversion repository
> under release/3.  Porting it to CHICKEN 4 may be a little trickier,
> because apparently it uses TinyCLOS, so you'd have to rework it to use
> coops:
> http://bugs.call-cc.org/browser/project/release/3/curl/trunk/curl.scm

Thanks. I will check easier ways first ...

> Out of curiosity, is there something important missing in the http-client
> egg, or are you trying to port some CHICKEN 3 code that used the curl egg?

The former.
I cannot find a way in http-client to specify a file attachment for sendgrid's 
API.
curl uses this syntax:
curl ... -F address@hidden;type=application/pdf

(see 
https://sendgrid.com/docs/API_Reference/Web_API/mail.html#-Send-a-test-specifying-the-file-content-type-by-appending-typemime-type-to-the-file-name
 )

The last line (marked *** below) is my best try so far, but it does not work:

                     (rest-action
                       "https://api.sendgrid.com/api/mail.send.json";
                       'PUT
                       `(
                         (api_user . "...")
                         (api_key . "...")
                         (to . ,to-address)
                         (from . "info@")
                         (subject . ,subject)
                         (,(if html? 'html 'text) . ,text)
                         (,(string->symbol (string-append "files[" attachment 
"]")) file: ,attachment filename: ,attachment headers: ((content-type 
,attachment-type))) ; ***
                         ))

(define (rest-action url method parameters)
  (vector->list (with-input-from-request
                 (make-request method: method uri: (uri-reference url)) 
parameters json-read)))

My code is based on the sendgrid egg.

Ciao
Sven



reply via email to

[Prev in Thread] Current Thread [Next in Thread]