unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Sébastien Rey-Coyrehourcq" <sebastien.rey-coyrehourcq@univ-rouen.fr>
To: guile-user@gnu.org
Subject: Some help needed to use curl lib to download binary file
Date: Fri, 29 Jul 2022 10:41:50 +0200	[thread overview]
Message-ID: <874jz01erv.fsf@univ-rouen.fr> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 1276 bytes --]

Hi guile community,

I’m a new user, jumping into guix and guile in the same time,
i’m interested to build a module to download file stored on Zenodo platform, using curl to request their REST Api.

This is usefull for reproducibility, i need to recover some data from Zenodo before running guix package that compile simulation that use this data.

I built a first part, using some info i found about curl lib of guile, but i’m now blocked by the last part, writing the binary body retrieved by curl into some file on my disk.

Here the full script  on debian paste :  <https://paste.debian.net/1248702/>

My problem is probably here, i don’t know how to pass the byte of body (from (get-file get-file-link)) into some file, i try with and without “string->bytevector” body conversion, without success  :

;; report body content from url string
(define (get-file url)
  ((receive (response body) (http-get url #true) (string->bytevector body))))

;; write content into file
(call-with-output-file “download.zip” (lambda (current-output-port)
                                        (get-file get-file-link)
                                        (put-bytevector (current-output-port) body)))

Thanks for your help
Best regards,
S.RC.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 889 bytes --]

             reply	other threads:[~2022-07-29  8:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29  8:41 Sébastien Rey-Coyrehourcq [this message]
2022-07-29 10:25 ` Some help needed to use curl lib to download binary file Vivien Kraus
2022-08-01  7:48   ` Sébastien Rey-Coyrehourcq

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jz01erv.fsf@univ-rouen.fr \
    --to=sebastien.rey-coyrehourcq@univ-rouen.fr \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).