How to dynamically change image at URL (rename github file?)

Any luck? :slight_smile:

Sorry not yet. I started working on it and got distracted. Just making sure you are on 2.2.1 right?

I wasn’t at first, but it didn’t work after I updated either

I just tested it and it works for me. It does NOT work if it's a cloud endpoint, but does work with:

mappings {
    path("/image") {
        action: [
            GET: "getImage"


def getImage() {
	byte[] imageBytes = null
    def params = [
        uri: "",
        headers: ["Accept": "image/jpeg"]
    httpGet(params) { resp ->
        if(resp?.data != null) {
            imageBytes = new byte[resp?.data.available()]
        else {
            log.error "Null Response"
    log.debug imageBytes.size()
    render contentType: "image/jpeg", data: imageBytes, status: 200

Yup, that worked! Not sure what changed since pretty sure i tried that before. Maybe I hadn't upgraded to 2.2.1 then? Doesn't matter now I suppose, because that worked. Thanks for your help on that!

1 Like