Forum OpenACS Development: Re: how to import image via url?

Collapse
Posted by Torben Brosten on
So.. the image is collected in to a variable, and then saved into the file system.

I assumed these only worked for text, and that binary encoded files would be handled differently. Thank you!

Collapse
Posted by Tom Jackson on

Torben,

Part of the problems is that there are so many ways to do it that are good, a lot of people roll their own to get exactly what they want. For instance, I have been looking at the new ns_http which is only available in AOLserver 4.5 (maybe ported to naviserver, but not in earlier AOLservers). This is good for handing off work to another thread. You can queue the request and an smart client thread could go about handling the details of download, retry, etc. You can't really do that in a connection thread. Or, you could queue the request, close the connection with [ns_conn close] then do a [ns_http wait] on the queued request. One advantage is that [ns_http queue] will complain if the request url doesn't look valid. Essentially, you simplify the logic of building a smart client. Nobody's really done it yet.

The four Tcl level AOLserver commands are ns_httpget, ns_httppost, ns_httpsget or ns_httpspost

Since these commands use ns_sock commands, the result should be 'binary', or exactly as received with no encoding conversions of other modifications. You should be able to open a file, fconfigure -binary and write the result.