reflex icon indicating copy to clipboard operation
reflex copied to clipboard

`get_upload_url` does not work as expected

Open bin-san opened this issue 1 year ago β€’ 1 comments

class ImageOperationState(r.State):
    source_image:str = '/sample.jpg'

class SomeState(r.State):
    imgopst = await self.get_state(ImageOperationState)
    imgopst.source_image = r.get_upload_url(outfile) # this would not work

printing the source_image gives:

<reflex.Var>{"state": "", "interpolations": [[0, 28]], "imports": {"/utils/state": [{"tag": "getBackendURL", "is_default": false, "alias": null, "install": true, "render": true, "transpile": false}], "/env.json": [{"tag": "env", "is_default": true, "alias": null, "install": true, "render": true, "transpile": false}]}, "hooks": {}, "string_length": 114}</reflex.Var>{${getBackendURL(env.UPLOAD)}/uploaded_files/test2.png-1a6d83df-f67a-4ff6-bc13-ae2214abab93-1719775789482107314}

Instead of the image path

bin-san avatar Jun 30 '24 19:06 bin-san

is it feasible to move the rx.get_upload_url bit to the frontend code and only store outfile in the ImageOperationState?

get_upload_url is intended for frontend rendering, but it does sort of work on the backend for the limited case of being passed to rx.download

masenf avatar Jul 01 '24 17:07 masenf

works as expected, rx.get_upload_url isn't supposed to be used in frontend not backend, as such, it returns a var

adhami3310 avatar Feb 05 '25 01:02 adhami3310