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

**URL:** <https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 15, 2021, 9:08am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989 "2021-09-15T09:08:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [September 15, 2021, 9:08am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/1 "2021-09-15T09:08:55Z")

</div>

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.

```auto
def runAction(self, event):
	# Grab the selected row
	selectedRow = self.getSibling("Table").props.selection.selectedRow
	pyDS=system.dataset.toPyDataSet(self.getSibling("Table").props.data)
	id=pyDS[selectedRow][0]

	# 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]
	self.getSibling("Label").props.text=filename
	# Download the file
	system.perspective.download(filename, filedata)

```

![下载1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/3/a3d6f7bee3c1b77c2755aa51a50e5cd0a7869edc.png)  
 ![下载2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/3/23b1c656a646ba420cbff8f63190b214e30538cf.png)  
 ![下载3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/2/f224fa700ea07f496c6ba28a9b80adc3702e50f9.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/0/a02d329bcb44003deb6fde3802cf9390527cf2c1.png)

Thanks for any advice and help.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [September 15, 2021, 9:22am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/2 "2021-09-15T09:22:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [September 15, 2021, 9:27am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/3 "2021-09-15T09:27:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [September 15, 2021, 9:33am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/4 "2021-09-15T09:33:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [September 15, 2021, 9:38am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/5 "2021-09-15T09:38:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [September 15, 2021, 10:49am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/6 "2021-09-15T10:49:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [September 15, 2021, 1:16pm UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/7 "2021-09-15T13:16:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [September 15, 2021, 2:13pm UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/8 "2021-09-15T14:13:13Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [September 15, 2021, 2:55pm UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/9 "2021-09-15T14:55:36Z")

</div>

Thanks

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 16, 2021, 8:52pm UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/10 "2021-09-16T20:52:03Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/c/fc98bc38f985c000dffe0701d17a350e8f8e331c.png)

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

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [September 17, 2021, 6:48am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/11 "2021-09-17T06:48:41Z")

</div>

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

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/7/77acb076388d662ae80932fe3e4e22367f94201e.png)

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 🙂

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [September 17, 2021, 9:23am UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/12 "2021-09-17T09:23:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 17, 2021, 2:23pm UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/13 "2021-09-17T14:23:38Z")

</div>

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](https://datatracker.ietf.org/doc/html/rfc2047) dictates that this header name and value be US-ASCII, which we are _not_ correctly encoding to.  
I’ll file the ticket.

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [September 17, 2021, 3:46pm UTC](https://forum.inductiveautomation.com/t/ign-4484-system-perspective-download-get-wrong-file-name/50989/14 "2021-09-17T15:46:24Z")

</div>

Thank you.
