@heefoo has joined the channel
@raymond.machira has joined the channel
`(define (download-image)
(define post (search-safebooru))
(define url (hash-ref post 'file_url))
(define md5 (hash-ref post 'md5))
(define file-ext (hash-ref post 'file_ext))
(define filename (string-append md5 "." file-ext))
(call-with-output-file filename
(lambda (in) (display (port->bytes (get-pure-port (string->url url)))in))
#:exists 'replace)
(define image (file->bytes filename))
(define data
(string-append
"--" boundary CRLF "Content-Disposition: form-data; name=\"file\"; filename=" filename CRLF "Content-Type: image/" (string-append file-ext CRLF))) image (string-append CRLF "--" boundary "--" CRLF))
(define (upload-image)
(define-values (status headers response)
(http-sendrecv server (string-append "/api/v1/media") #:ssl? #t #:method #"POST" #:headers (list (string-append "Content-Type: multipart/form-data; boundary=" boundary)(string-append "Authorization: Bearer " token)) #:data (download-image)))
(displayln (read-json response)))
Am I doing multipart form requests right?
this is what i got by following a snippet i see online when i run this i just get 500 internal server error