asynchttpGet get byte data

How does this look?

void imageTest() {
    def params = [
        uri: "https://www.w3.org/MarkUp/Test/xhtml-print/20050519/tests/jpeg444.jpg",
        headers: ["Accept": "image/jpeg"]
	]
	asynchttpGet(sendHttpResponse, params)
}

void sendHttpResponse(response, data) {
    if(response.data != null) {
        log.debug "base 64 data size ${response.data.length()}"
        byte[] imageBytes = response.data.decodeBase64()
        log.debug "bytes size = ${imageBytes.size()}"
    }
}

Output:

[app:4624] 2020-05-11 05:36:26.065 pm [debug] bytes size = 5667
[app:4624] 2020-05-11 05:36:26.064 pm [debug] base 64 data size 7556
2 Likes

did this method work for you ?

I'm trying to do the same thing. data is received (not null)
but when I encode and use it in a multipart/form element, it just shows a blank image.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.