Multiple triggering event Change on image uploader


Goal - create records in Firebase with link to uploaded files to Storage.

Steps - I need to create records with links to images. As a first step I need to upload file to Firebase Storage and get signed link. Then I will be able to use this link and save in record.

I have 1 request for file uploading where I provide data and file path.
I want to keep it smart bcs I have multiple uploaders on page so I run JS script to save path of uploaded file into the variable. During saving the record I can use variable to get needed path to the file.

Everything works fine but I have problems with running JS query on uploader change. It doesn't work well - trigger works only every 2-3rd upload (I upload and clear).
It has simple logic to checking if number of files =0 or not.


Upload file request

Condition on uploading

Condition on clearing

JS code running on upload

Record insert request with use of variable with picture path

Do you get any errors in the console when it does not upload?

I'm not sure any of this is your problem but some things:
you don't need new, I'm not sure if the compiler processes it or not but visually it looks like you're trying to get a promise (calling .trigger()) then create a new promise and await it.

{{fileInput_user_adminnote_image.value.length===0}} left hand and right hand sides should always be an int, just in case though it's best to not let the compiler "coerce" or cast stuff with ==.... if you accidently mis-structured/labeled props or keys in your variable there's a chance js would try and coerce it to an integer producing odd results at odd times.

this could be a naming collision? have you tried using a diff var name?

I don't know what the value of data is here. the request claims its image/png but if that value is from retool it's got pretty good odds of actually being a base64 string in which case you might want to try changing it Content-Type: binary or pre-fixing the data value from addition scope w {{ 'data:image/png;base64,' + data }}

1 Like

Thank you so much!
Something of it helped.

1 Like

Another problem within this case - fileinput clearValue() and resetValue() functions doesn't work. I choose the file, upload it, trigger function and nothing happens, I still see selected file

i just tried in a new app and .clearValue() worked for me.

could you share the code, or the part that has to do with clearing the value? don't forget to use mspaint or something to hide any sensitive info if your able to show us. otherwise it's a bit difficult to know what's going on. it sounds like there might be conditional or comparison (usually from using == instead of ===) that isn't evaluating correctly leading to that part of the code being skipped. thats just a guess though.