How to access URL of image uploaded via picture uploaded (SSA)?

I’m creating a server side action that calls the Replicate API. These are the parameters I’m sending via the GET call:

let requestBody = {
    version: "9283608cc6b7be6b65a8e44983db012355fde4132009bf99d976b2f0896856a3",
    input: {
        img: 'https://scontent-lhr8-1.xx.fbcdn.net/v/t1.6435-9/57308609_10157305731489319_5665168481692155904_n.jpg?_nc_cat=103&ccb=1-7&_nc_sid=8bfeb9&_nc_ohc=h0fyo5bFEgwAX8l_YeC&_nc_oc=AQkOlIwT9pAlEeKnaRxXypwWe1ky5IUS76lQEoPXTx4uZXx3BmwDinUB4E_4JX6F3z0&_nc_ht=scontent-lhr8-1.xx&oh=00_AfD6taAuCkGD_A6Ou_ylPv6Fuv7hm9K3__X22luzBAvfhw&oe=65182469',
        scale: 2,
		version: 'v1.4',
    }
};

You’ll notice the “img” input is the actual URL of an image. This works fine. When I run the action in my test app…

2023-08-31 17.01.08

…the prediction gets processed in Replicate. This is the output, which I’m very happy with:

However, whenever I obviously want to make the image URL dynamic. But when I try to set the image value to “PictureUploaderA’s value’s URL”:

and change my plugin code accordingly:

let requestBody = {
    version: "9283608cc6b7be6b65a8e44983db012355fde4132009bf99d976b2f0896856a3",
    input: {
        img: properties.image,
        scale: 2,
		version: 'v1.4',
    }
};

It doesn’t work. The call is not being made successfully.

This is the error code I’m getting:

{"detail":"- input.img: Does not match format 'uri'\n","status":422,"title":"Input validation failed","invalid_fields":[{"type":"format","field":"input.img","description":"Does not match format 'uri'"}]}

Anyone have any idea what I can do to fix this error? Looks like I need to convert the URL to a uri somehow?

Any assistance would be much appreciated :slight_smile:

Try prepending picture uploader URL with “https:”.

2 Likes

Can you explain why you are doing a plugin using SSA instead of API Connector?

That worked! Thanks so much @vladimir.pak :slight_smile:

I have some conditional “if” statements that are easier to code in javascript vs. using the API Connector.

Also I like the format of the fields on the actions (rather than the “body” or “path” you get with the API Connector :slight_smile:

Just consider that it may cost you more in capacity unit and it’s often slower than API Connector. Also, it’s easier to work with the response in API Connector from my point of view (more when the payload is large).
Conditionnal can be done in Vanilla Bubble in most case.

1 Like

Good points. Thanks for pointing that out @Jici :slight_smile: I’ll have a think about using the API Connector instead.

You’re welcome. However, there’s some case where I really understand the use of SSA. But for this case, I’m not sure actually it’s the best option. But for complex conditionnal… it’s something to consider yes (see also challenge from @adamhholmes where we talk about something that can be really simple in JS while it’s more complicated in Bubble directly)

2 Likes