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

Collapse
Posted by Tom Jackson on

In AOLserver 4.5, the following works for me:

set id [ns_http queue http://192.168.1.102:8000/sns-thumb.jpg]

set ok [ns_http wait -result image -status status $id]

if {"$status" == "200"} {
    set fd [open [file join [file dirname [info script]] myimage.jpg] w+]
} else {
    ns_return $status text/html $image
    return -code return
}

# Very important:
fconfigure $fd -translation binary

puts $fd $image
close $fd

ns_return $status text/html "Status: $status <br>
<la href=\"/myimage.jpg\">My Image</a>"

ns_http queue and ns_http wait can be in different threads.