[IGN-8219] Perspective File Upload onFileReceived being called twice

Hello,

I'm using the perspective FileUpload Component to upload images to a database using the following code in the OnFileReceived component event:

query = 'INSERT INTO [Table] ([ID],[Name],[Image]) VALUES (?,?,?)'
system.db.runPrepUpdate(query, [self.view.params.ID, event.file.name, event.file.getBytes()], 'DB')

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.

Any help would be appreciated.

Thank you,
Matthew

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.

1 Like

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'm in the same boat here, using edge 116.0.1938.76 on windows 10, Ignition 8.1.31.

The onFileReceived is firing twice off the upload file component.

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 = ''

I'm seeing this behavior in Chrome in 8.1.31.

chrome_hIYTOtlQLK

Thanks for the reports, we're tracking this bug.

2 Likes

Same problem here:
Ignition 8.1.31 (b2023081007)
Edge Version 119.0.2151.72

Thanks @joshdunstan for sharing your workaround!

1 Like

Did you found any solution for that? I am also getting the exact issues.

Looks like this was fixed in the most recent nightly.

3 Likes

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.

3 Likes

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.