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

Collapse
Posted by Torben Brosten on

It's not working for me..

Heres the code in the tcl page:

ad_page_contract {
    @ test
} {
    { url "http://kappacorp.com/fwgoofiness.jpg" }
}

if {[catch {set get_id [ns_http queue GET $url]} err ]} {
    set page $err
} else {
    set status [ns_http wait $get_id page]

    if { $status eq 1 } {
        ns_log Notice "get-image.tcl status $status , page $page"
    } else {
        # no page info returned, just record warning                                                                                                                                       
        ns_log Notice "ref 101: Error: status: $status , url: $url , page: $page"
    }
}
ns_return 200 image/jpeg $page

Whatever the image, it seems that 9 bytes are returned that get interpreted as 4 or 5 nonstandard characters.. depending on the interface. What am I doing wrong?