It works in that it uploads the image to the database but for some reason the onFileReceived event is being called twice for every image that is uploaded.
It's happening in a browser as well as in the perspective app.
Hi @Matthew.gaitan, that’s not a behavior that we’ve seen before. Just to debug, have you tried making a sample view with just the File Upload component (separate of the instance where you are seeing this error) and logging to the console on upload? If you’re still seeing that error with that sample view, please post back, but I imagine there is some type of duplicate logic somewhere that is causing what you are seeing.
It looks like onFileReceived fires twice in Firefox but not IOS. Adding a system.perspective.print and no other code results in two logs in the console.
I easily get around it by modifying the code to check the filename to ensure we don't do the same file twice in a row:
def runAction(self, event):
# Grab the file name and data
filename = event.file.name
filedata = event.file.getString()
# Check if this file has just been uploaded - to stop a double import (potential platform/browser bug)
if filename <> self.custom.filename:
# Call the import function on the table
self.parent.parent.getChild("Table").importCSV(filename, filedata)
self.custom.filename = filename
else:
self.custom.filename = ''
It has indeed been fixed, but there is some question as to whether the content made it into the nightly. There was an expedited release yesterday (8.1.35, which contained only one important fix which was a problem in 8.1.34), and our release mechanisms might not have caught up. It will absolutely be part of the 8.1.36 release.
Initially, i am using the size of file <30kb so i am getting issue. Then i maintain the size of same image file between >500kb &<550kb but still same issue is happening.
Any suggestion what size of file should be there so that the event can't fire twicely.