NetTalk Central

Author Topic: File Download issue with name  (Read 3764 times)

mmelby

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
File Download issue with name
« on: February 10, 2022, 07:17:52 AM »
I am struggling with the very last part of my project. I added a button to download/export a file. The button calls a NetWebPage to create the file and present it for downloading. The file gets created and put in the Web folder correctly but when it gets downloaded to the client the file data is correct but the name is different and I cannot figure out how to fix this. The name of the file I create is ExportISE.csv. That is the name that is on the Web folder. The file name that gets downloaded to the client is ExportFile.xls. That file name is nowhere in my program. I have attached a sample program that shows the behavior. The login is Export/Export1.

Any assistance is greatly appreciated.

Regards,
   Mike

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: File Download issue with name
« Reply #1 on: February 10, 2022, 01:06:38 PM »
Its a MIME problem, NT is not choosing the correct one.
Its choosing: application/vnd.ms-excel and you need text/csv
May be Bruce can be more accurate on this.

Goto source of the export proc, search for Header routine and add:

  p_web.ReplyContentType = 'text/csv'

at the end

See pic.

By the way, here you have all mime types:
https://developer.mozilla.org/es/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

« Last Edit: February 10, 2022, 01:12:21 PM by Alberto »
-----------
Regards
Alberto

mmelby

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: File Download issue with name
« Reply #2 on: February 10, 2022, 02:46:23 PM »
Thank you! That fixed the extension issue. Any idea how to fix the file name issue? The name that now gets downloaded is ExportFile.csv. Any idea how to change the file name? I cannot find the name ExportFile anywhere in my program.

Again, thank you for you help.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File Download issue with name
« Reply #3 on: February 10, 2022, 08:59:29 PM »
>> I cannot find the name ExportFile anywhere in my program.

It's literally the name of the procedure the client is calling. It is the URL they are requesting, they get back a file, so they save i with that name.

the "File Download (40)" example contains what you are really chasing.

p_web.HeaderDetails.ContentDisposition = 'attachment; filename="ExportISE.CSV"'
and then you can override the mime time as Alberto suggested.

cheers
Bruce

mmelby

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: File Download issue with name
« Reply #4 on: February 11, 2022, 05:22:47 AM »
I hate it when I miss something so obvious. All is working as expected.

As always, thank you for your time!

Regards,

Mike