Forum OpenACS Development: Re: ns_http instead of curl for posting files

Collapse
Posted by Antonio Pisano on

Dear Malte,

if your instance uses OpenACS, the util::http::post[1] should let you upload files without much trouble using an idiom like:

util::http::post -url https://example.domain.com -files {{file /tmp/file1 fieldname upload-file}}

This should use the correct multipart format out of the box.

If you want to use the ns_http directly, you need to construct the body yourself. If the receiving backend is under your control, maybe a PUT would be more convenient, something like:

ns_http run -method PUT -headers $headers -body_file $file $url

Hope this helps

Antonio

[1] https://openacs.org/api-doc/proc-view?proc=util::http::post&source_p=1