one thing we do, is we store the MIME type in the database, and we don't have those problems. I think you need to use the specific mime type for the type of file you are serving, like application/pdf or whatever. Also, I don't think you need the NAME in the content-type header.

One last thing, many browsers will now balk at you if you do not have a content-length header, you should be specifying content-length header on every download like this. Not only will this make your code more compatible, but it will also make downloading a more pleasant experience for your clients. When you download without content-length, the client end will show an unknown and some barber pole like progress, cuz it has no idea when the file ends.

I believe those 2 issues, mime-type and content-length will solve your problems. There is one more mine field.

Other languages, like php, automatically do content-length for you, so it is much better and I have found always accurate. Witango is different story. Witango treats every variable like TEXT, not binary data, so every so often, when you do

<@length "@VARlocal$fileContents encoding=none>">

The resulting length will be off slightly, usually by one byte. This is one of those times where I beat my head against walls trying to figure this one out. It seemed to happen on about 1 out of every few hundred files, but it would occur on the same file every time, and will cause the file to be corrupted on download. Unfortunately, there is no way around this on witango. There is no way to know which binary files will do this in witango, so you can't do some type of IF, and add or subtract a byte to length.

So, in order to have a full proof compatible digital delivery system in witango, we have found the best way is to handle these things on upload. On upload, or when the files are stored, we would populate the mime-type in the database, and we would run a witango external command that would return the length of the file, correctly, to store in the db to be used on content-length on time of distribution. You can also add those files to your database, and then use a binary length function in a select command to get the length if you db supports it and you are using blobs. I believe mysql does.

This is one of those cases, and their are many, where you really have to way out certain applications and witango. The ease of use on other areas, get totally negated when you run into issues like this. Uploading and distributing binary files in php for example, is incredibly simple and robust, just a few lines of code. Witango can be as reliable, but you have to get around the content-length issue.

--

Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
[EMAIL PROTECTED] - [EMAIL PROTECTED]
http://bighead.net/ - http://eventpix.com/

On Dec 13, 2007, at 3:57 AM, Mike Scally wrote:

Hi All,

Maybe someone can help me out here. We have a document management system written in Witango, and as part of the system we restrict access to files based on the users profile. When a user requests a file, we check their credentials and then send the file back to them using the following (where fileContents contains the contents of the file):

<@PURGERESULTS><@ASSIGN request$httpHeader "HTTP/1.1 <@HTTPSTATUSCODE> <@HTTPREASONPHRASE> <@crlf>Server: Witango<@version><@crlf>Content-Type: application/octet-stream; name=<@VAR LOCAL$fileName ENCODING=NONE><@CRLF>Content-Disposition: inline; filename=<@VAR LOCAL$fileName ENCODING=NONE><@CRLF><@IF EXPR='len(<@USERREFERENCECOOKIE>)' TRUE='<@USERREFERENCECOOKIE>'><@crlf>"><@VARlocal$fileContents encoding=none>

This application was untouched for some years, and it always served the files correctly including PDF files. The user got the Open, Save and Cancel dialog for known file types. However, after we installed Adobe Reader 8.0+, we no longer get the option to Open the PDF files directly, but can only Save them to the file system. I have included the HTTP response header below. Should Content-Type be set differently to give the Open option? If I specifically set it to “application/pdf”, I get the open file option, but I cannot do this as we server all different file types. Maybe someone is doing something similar and may have run into the same problem.

-----------------------------------HTTP Header------------------------------------------
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Thu, 13 Dec 2007 11:39:32 GMT
X-Powered-By: ASP.NET
Connection: close
Server: Witango 5.5.003 Liquorice (Win32)
Content-Type: application/octet-stream; name=Certificate.pdf
Content-Disposition: inline; filename=Certificate.pdf

PDF contents start here……
------------------------------------------------------------------


Any help greatly appreciated.

Thanks
Mike.
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf


________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to