File Upload In Progress

Does anyone have a solution to know when a file being uploaded is still uploading?
I’m trying to disable a button while files are being uploaded. I tried using the onFileReceived event but the button is disabled after the file has been uploaded.

Thanks.

What does the code within your onFileReceived Event look like?

@cmallonee

self.getSibling("Button").props.enabled = False # this executes after the 1st file is uploaded
fileName = event.file.name
fileBytes = event.file.getBytes()
query = "INSERT INTO table (fileName, fileBytes) VALUES (?, ?)"
args = [fileName, fileBytes]
system.db.runPrepUpdate(query, args)

Edit: I think the event trigger makes sense (onFilesReceived). Almost need another event onFilesReceiving that would trigger when the component starts uploading the file to the gateway?

I think we could benefit from onFileSubmit and onSubmitComplete Events which fire before any files are uploaded and then after all file have completed (whether they all succeeded or not). I’ve reached out to a Dev to see if these Events would be possible. FOr now we don’t see a good way for you to disable a button when the uploads start and then enable when the uploads complete.

self.getSibling("Button").props.enabled = False # this executes after the 1st file is uploaded
fileName = event.file.name
fileBytes = event.file.getBytes()
query = "INSERT INTO table (fileName, fileBytes) VALUES (?, ?)"
args = [fileName, fileBytes]
system.db.runPrepUpdate(query, args)
self.getSibling("Button").props.enabled = True

Would sort of work, but I suspect the state of the button would flicker between files as it enables upon completion and then immediately becomes disabled. This did NOT occur when I tested it (the transition was so fast that it couldn’t even be seen, though logging did indicate the button toggled state).

1 Like

Those additional events would be great. Not a deal breaker by any means but would be nice to have.

Thanks for reaching out.

1 Like