[IGN-4484]System.perspective.download get wrong file name

Here are three files, two of them get wrong file name.

一.txt → txt
二 → 二.txt
Three.txt → Three.txt

Here is the script on button.
I think the function get the right parameters.

def runAction(self, event):
	# Grab the selected row
	selectedRow = self.getSibling("Table").props.selection.selectedRow

	# Use the id to grab the file data out of the database, along with its corresponding name.
	query = "SELECT filename, filedata FROM Files WHERE id = ?"
	args = [id]
	data = system.db.runPrepQuery(query, args, database='file')
	# Pull out the file name and data
	filename = data[0][0]
	filedata = data[0][1]
	# Download the file
	system.perspective.download(filename, filedata)


Thanks for any advice and help.

does your machine support such characters as filenames? (can you create them with the right name by hand?)

Yes,I created txt files and renamed them,then upload them.
And the client and gateway is on the same one PC.

can you download files with that name from a different source like idk googledrive?
maybe its the browser that has problems?

you might have to contact support

Yes, they work well in my email. The names are basic chinese word, and I’m sure their code is utf-8.

welh there seems to be a problem with encoding so maybe try to use a different encoding i guess
filename = filename.encode('utf-8')

I don’t think that is an encoding problem. The second file showed right word, but with Extensions that shouldn’t exist.
And I encoded the filename to utf-8 before upload them.

Anyway, I’ll try your advice tomorrow.

i mean i dont see what else it could be xd three.txt sure is working like normal so idk
and it might be ignition that turns the filename into unicode again, it does that a lot…

1 Like


A directly scripted attempt (system.perspective.download("二", "data")) worked fine for me:

If you system.perspective.print the filenames before calling system.perspective.download, are they showing up correctly?
What Ignition version is this?

I guess yes, but here is an encoding error in console.


Please allow me to recapitulate the phenomenon on my PC.
First file get no file name but just extension.
Second file get correct file name but with extension that shouldn’t exist.

The first phenomenon is a real problem. when I tried to find out, I noticed the second one. Files without extensions are not commonly used, so I think that is acceptable.

Ignition version is 8.1.7 , windows 10.

Thank you :slight_smile:

I upgraded to 8.1.10 just now, and the problem remains.

I found the bug. We’re passing the Content-Disposition header from the backend, which is what suggests the filename to the browser. However, RFC-2047 dictates that this header name and value be US-ASCII, which we are not correctly encoding to.
I’ll file the ticket.


Thank you.