Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

file download problem

osuwariboyosuwariboy Members
edited July 2014 in Sahi - Open Source
Hey there everyone, I have a problem with file download in Sahi. I'm trying to download some files from an external website and I'm getting some weird behavior from Sahi. For one thing, when I click on the link, it opens a new window, so I did this:

_sendHTMLResponseAfterFileDownload(true);
_click(_link($nomLien));
_saveDownloadedAs("test.XLSX");
_sendHTMLResponseAfterFileDownload(false);

And also, here's the console output from Sahi:

-- Calling downloadFile --
https://www.agep-gbip.dsf-dfs.com/AGEP-GBIP/Rpprt/Rapports3_Reports3.aspx?mode=N
IF&culture=fr-CA&idRapport=40F55E83-D37C-4625-A2E9-29655643E98B
downloadURL = true
response.isAttachment() = false
fileName = Rapports3_Reports3.aspx
contentTypeHeader = application/vnd.openxmlformats-officedocument.spreadsheetml.
sheet.main+xml; charset=iso-8859-1
downloadContentType = true
Content-Disposition=attachment; filename="Liste des adhérents en vigueur et leurs garanties - Au 2014-06-30.XLSX"
contentDispositionForcesDownload = false
--
juil. 15, 2014 4:45:26 PM net.sf.sahi.RemoteRequestProcessor save
INFO: Downloading sahi_1a6a5837005ff042e40a53600dc9abe2baaf__Rapports3_Reports3.aspx to temp directory:
C:\Sahi\userdata\temp\download
juil. 15, 2014 4:45:26 PM net.sf.sahi.RemoteRequestProcessor downloadFile
INFO: Setting download_lastFile = Rapports3_Reports3.aspx
Session Id: sahi_1a6a5837005ff042e40a53600dc9abe2baaf

Now, I have a few problems. Here's the list:

1) Instead of the actual file, download_lastFile is set to the name of the page that actually starts the download and not the name of the file
2) _saveDownloadedAs creates an empty file while the actual file is downloaded in the default temp folder.
3) Sahi injects html inside the downloaded file rendering it unreadable unless I actually delete the added content.

Anybody have any idea? I added

.*Rapports3_Reports3[.]aspx.*

to the exclude_inject.txt file without success. Anyone has any idea?

Thanks in advance,

Osuwariboy

Answers

  • sahirsahir Members
    Hi,

    adding the mime-type of your xls-file could solve the problem. Just add it to userdata/config/download_contenttypes.txt.
    If sahi cannot access the file it always creates an empty file with the given name.
Sign In or Register to comment.