Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: File Download Questions

$
0
0
Re: File Download Questions
Web Connection 5.0
Re: File Download Questions
12/08/2011
03:58:47 PM
3DN0Y8661 Show this entire thread in new window
From:
To:
Mike McDonald
Attachments:
None
This does not to me explain why this code works:
If File(lcFile) Response.AppendHeader("Content-type","application/octet-stream") Response.AppendHeader("Content-disposition","attachment; filename="+JustFName(lcFile)) Response.FastWrite(FileToStr(lcFile)) * Response.DownloadFile(lcFile,"application/octet-stream",JustFName(lcFile)) Else This.Form_LoadTables_Post This.cMessage="Download failed because file: "+lcFile+" does not exist." Response.ExpandTemplate(This.cHTMLPagePath+"dDnload.htm") Close Databases EndIf

and this code does not work:

If File(lcFile) * Response.AppendHeader("Content-type","application/octet-stream") * Response.AppendHeader("Content-disposition","attachment; filename="+JustFName(lcFile)) * Response.FastWrite(FileToStr(lcFile)) Response.DownloadFile(lcFile,"application/octet-stream",JustFName(lcFile)) Else This.Form_LoadTables_Post This.cMessage="Download failed because file: "+lcFile+" does not exist." Response.ExpandTemplate(This.cHTMLPagePath+"dDnload.htm") Close Databases EndIf

lcFile is a UNC fle name.

Simon


Simon -


Today I changed my code to use DownloadFile() and I get the following message..

"Couldn't read the requested file on the server. Most likely permissions don't allow access to the requested file."

The file is actually located on another server and is accessed using UNC names.


That message is coming from the wc.dll, as the path and filename is based on the server where wc.dll is located. It may be that the UNC path and file name isn't valid from that server, and then you would get this message. Instead of a permissions issue, it may be an issue of wc.dll not seeing the file.

Note that if the path to the file is different on your two servers, and you change the filename to be based on the server where wc.dll resides (instead of the server where your app is running), then you'll get a 404 response on the client end. This is actually being sent from wwResponse::DownloadFile(), because that method checks to make sure the file exists too.

What we have done is subclassed the method to allow sending two filename parameters - one that is used for the app file checking, and one that is sent to wc.dll. If only one filename is passed, it is used for both.

Also, DownloadFile() calls to TransmitFile(), which also checks the filename, so if this is your issue, then that method would have to be changed as well. We actually just subclassed the TransmitFile() method to receive the two filenames. This was a long time ago, possibly before DownloadFile() was available. In any case, we just use TransmitFile().

Hope this helps.

- Mike McDonald
Software Design of Kentucky

Hi

In the past I have used Response.FastWrite(FileToStr(myfile)) to download files using web-connect (after properly configuring the header for file downloading). Today I changed my code to use DownloadFile() and I get the following message which I never got using the FileToStr() function. The file is actually located on another server and is accessed using UNC names.

"Couldn't read the requested file on the server. Most likely permissions don't allow access to the requested file."

1) What security setting need to be changed to make DownLoadFile() work correctly.
2) Is there a limit to the size of file that can be downloaded. I want to be able to download files in the 100's of megabytes. Ideally I would like to download any file size.

Thanks,
Simon




Viewing all articles
Browse latest Browse all 10393

Trending Articles