Well folks,

I never did get this to work. I tried everything and could never get a jpg
or gif that wasn't corrupted somehow. I even compared file sizes and they
were exactly the same from the original. I went as far as thinking that the
read function was corrupting the file so I created a read, loaded a variable
and then wrote that variable to a different directory to see if the jpg
would corrupt and guess what?... that worked fine... in other words, this
does not seem to be a Witango problem because a can read and write without
any corruption whatsoever. It appears to be an IIS problem. All of these
were tested on MAC and PC using IE and Firefox... none of them worked.

So I decided to bite the bullet and I created a directory structure and
changed the mime types in those directories in IIS for gif and jpg to
x-application/attachment and it works flawlessly for both gifs and jpgs. Oh
well. Guess I'll have to update the images in 2 places rather then one. Not
a big deal... there are only about 3000 images. I appreciate the help
anyway. I have done header rewrites in the past for purging cache and such
and never had a problem, I just couldn't get this to work and the amount of
time I was spending on this for the client was a bit beyond what the client
was going to pay. Here are the 4 header rewrites that I tried to no avail,
if anyone is interested...

<@purgeresults><@ASSIGN local$httpHeader VALUE="HTTP/1.0 200
OK<@crlf>MIME-Version: 1.0<@crlf>Content-Type:
application/jpg<@CRLF>Content-Disposition: attachment; filename=<@VAR
filename><@CRLF><@USERREFERENCECOOKIE><@CRLF><@CRLF>"><@VAR FileData
scope="local">

<@assign name="httpHeader" scope="local" value="HTTP/1.0 200
OK<@crlf>MIME-Version: 1.0<@crlf>Content-type:
application/jpg<@crlf>Content-Disposition: attachment; filename=<@VAR
filename><@crlf>Content-Length: <@VARINFO NAME="FileData"
size><@crlf><@crlf>"><@purgeresults><@VAR FileData scope="local">

<@purgeresults><@assign local$httpHeader 'HTTP/1.0 200
OK<@crlf>Content-Type: image/jpeg; filename="<@VAR
filename>"<@CRLF>Content-Disposition: attachment; filename="<@VAR
filename>"<@CRLF><@CRLF>'><@var local$FileData encoding=none>

<@ASSIGN httpHeader VALUE="HTTP/1.0 200 OK<@crlf>MIME-Version:
1.0<@crlf>Content-Type: image/jpeg<@CRLF>Content-Disposition: attachment;
filename=<@VAR filename><@CRLF><@CRLF>"><@var local$FileData encoding=none>


Thanks again!


  _____

From: Robert Garcia [mailto:[email protected]]
Sent: Wednesday, March 30, 2011 1:18 AM
To: [email protected]
Subject: Re: Witango-Talk: Forcing jpg Download


So I found a taf from one of the more recent applications I had done in
witango.

First, I have a data action that gets data from db, this is in the results
for that action:

<@assign local$image <@column "hiRez.image" encoding=none>>
<@assign local$cLength <@column "hiRez.data_size" encoding=none>>

Then a results only action to assign header, notice use of <@exclude> to
allow nice formatting, but not add anything to the result buffer:

<@exclude>
<@ifempty <@arg filename>>
    <@assign local$fileName "image.jpg">
<@else>
    <@assign local$fileName <@arg fileName>>
</@if>
<@assign local$httpHeader 'HTTP/1.1 200 OK<@crlf>Server: WiTango Server
4.05.047<@crlf>MIME-Version: 1.0<@crlf>Content-Type:
application/download<@crlf>Content-disposition: attachment; filename="<@var
local$fileName>"<@crlf>Content-length: <@var local$cLength><@crlf>Expires:
-1<@crlf><@crlf>'>
<@assign local$encodehttpresponse "False">
</@exclude>

And then a final results only results page for the image data:

<@purgeresults><@var local$image encoding=none>

A couple of notes.

1. I am aware of deprecation of local scope, this is not in service anymore.
2. Before we started storing the content-length in the DB, we would get it
like this:

<@assign local$cLength <@length <@column "hiRez.image" encoding=none>>>

This worked reliably, this was not for eventpix, but for a large image
library website, stock photography and such. The only issue with the above
was that sometimes @length would be 1 byte off, and cause an issue.

On 3/29/2011 4:18 PM, Robert Garcia wrote:

Also Disposition inline will not download, must be attachment.

--Â

Robert Garcia
BigHead Technology
15520 Coutelenc Rd
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
[email protected]http://bighead.net/
Sent with Sparrow <http://bit.ly/sigsprw>


On Tuesday, March 29, 2011 at 3:49 PM, Ben Johansen wrote:


There alway needs to be 2 CRLF's after header info. So in your first example
you only have one and the 2nd you have the extra <@purge.

also, I don't there there is a mime type called "application/jpeg" it should
be "image/jpeg"

here is what I did for jpegs

<@purgeresults><@assign request$httpHeader 'HTTP/1.1 200
OK<@crlf>Content-Type: image/jpeg;
filename="mithumb.jpg"<@CRLF>Content-Disposition: inline;
filename="mithumb.jpg"<@CRLF><@CRLF>'><@var request$imagedata encoding=none>





On Mar 29, 2011, at 2:54 PM, WebDude wrote:


I appreciate the help so far. I feel I am 95% there.

I have tried this with these 2 header rewrites (all on one line, of
course)...

<@purgeresults><@ASSIGN local$httpHeader VALUE="HTTP/1.0 200
OK<@crlf>MIME-Version: 1.0<@crlf>Content-Type:
application/jpg<@CRLF>Content-Disposition: attachment; filename=<@VAR
filename><@CRLF><@USERREFERENCECOOKIE><@CRLF>"><@VAR FileData scope="local">




<@assign name="httpHeader" scope="local" value="HTTP/1.0 200
OK<@crlf>MIME-Version: 1.0<@crlf>Content-type:
application/jpg<@crlf>Content-Disposition: attachment; filename=<@VAR
filename><@crlf>Content-Length: <@VARINFO NAME="FileData"
size><@crlf><@crlf>"><@purgeresults><@VAR FileData scope="local">

I am assigning the filename from a search and writing the data to FileData

It actually finds the filename and downloads the file. The problem is that
the file seems to be corrupt. It will not display in a browser and when I
try to open it in PhotoShop I get the following error (I tried this in
multiple browsers)....

"Could not open the document because a JPEG marker segment length is too
short (the file may be truncated or incomplete).

Is there something else I may be missing?

I appreciate the help!




-----Original Message-----
From: Robert Shubert [mailto:[email protected]]
Sent: Tuesday, March 29, 2011 1:57 PM
To: [email protected]
Subject: RE: Witango-Talk: Forcing jpg Download

Yes - you have that correct.

-----Original Message-----
From: WebDude [mailto:[email protected]]
Sent: Tuesday, March 29, 2011 2:58 PM
To: [email protected]
Subject: RE: Witango-Talk: Forcing jpg Download

What do you mean by "Then you dump out the contents of the jpeg AFTER the
header." Do I read the jpg using the Read File Action as in what the other
Robert suggested? Is that what the <@VAR Request$FileData> is?

Mmmmm... I'll give it a shot...




-----Original Message-----
From: Robert Garcia [mailto:[email protected]]
Sent: Tuesday, March 29, 2011 1:28 PM
To: [email protected]
Cc: Robert Shubert
Subject: Re: Witango-Talk: Forcing jpg Download

We have done that many times before in witango. That is the correct header
you need to use, and attachment is the correct way. However, it looks like
you are trying to put the contents of the file in the filename part, that
header just takes the filename, and it should end in JPG or JPEG, or match
the mime of the content with the extension, or it may not work on all
browsers. Then you dump out the contents of the jpeg AFTER the header. Here
is an example I found from a TAF that I know we had working:

<@assign name="httpHeader" scope="request" value="HTTP/1.0 200
OK<@crlf>MIME-Version: 1.0<@crlf>Content-type:
application/download<@crlf>Content-Disposition: attachment;
filename=downloadreport.xls<@crlf>Content-Length: <@length
@@request$FileData><@crlf><@crlf>"><@purgeresults><@VAR Request$FileData>

It is important to know that you must NOT have ANY returns in this results
page where you use this code, it should be on one line. We do this in other
places with JPEGs, but we use image/jpeg for content-type, and a variable
usually for filename. Content-length is also important, but can be a big
buggy in witango.

On 3/29/2011 11:09 AM, Robert Shubert wrote:


In that case, I think you have the header correct. What you need to do

afterwards is use a Read File Action to bring the content of the JPEG

into Witango and then simply display it as the response. It's

important that you don't get any additional characters (like extra

returns or spaces in the result)


Robert


-----Original Message-----

From: WebDude [mailto:[email protected]]

Sent: Tuesday, March 29, 2011 1:49 PM

To: [email protected]

Subject: RE: Witango-Talk: Forcing jpg Download


<@COLUMN "images.LargerImage"> Â is the name of the file.





-----Original Message-----

From: Robert Shubert [mailto:[email protected]]

Sent: Tuesday, March 29, 2011 12:06 PM

To: [email protected]

Subject: RE: Witango-Talk: Forcing jpg Download


What is in the database column<@COLUMN "images.LargerImage">? Is this

the name of the image file or the binary JPEG data?


Robert


-----Original Message-----

From: WebDude [mailto:[email protected]]

Sent: Tuesday, March 29, 2011 12:45 PM

To: [email protected]

Subject: Witango-Talk: Forcing jpg Download


PHP has a handy header rewrite for forcing a jpg download. I was

wondering if anyone has ever done this in Witango. I've been able to

get this to work on IIS by changing the directory header, the problem

being is that I have 2 sites that reference the same images and one

needs to force a download and the other to view the image in a browser

(same images in the same directories).


I've been dabbling but can't seem to get it to work right. Of course

when I add header change to the top of the taf file, it tries to

download the taf file itself rather then the jpg file. This is stupid

I know, but what is the best way to force a download of a jpg and get

it to work? This is what I have so far. Am I missing something

fundamental


in trying to do this?



<@purgeresults><@ASSIGN local$httpHeader

VALUE="Content-Type:application/jpg<@CRLF>Content-Disposition:

attachment, filename='<@COLUMN

"images.LargerImage">'<@CRLF>readfile('<@COLUMN

"images.LargerImage">')<@CRLF><@USERREFERENCECOOKIE><@CRLF>">


Thanks for your thoughts...




WebDude





----------------------------------------


To unsubscribe from this list, please send an email to

[email protected] with "unsubscribe witango-talk" in the body.




----------------------------------------


To unsubscribe from this list, please send an email to

[email protected] with "unsubscribe witango-talk" in the body.




----------------------------------------


To unsubscribe from this list, please send an email to


[email protected] with "unsubscribe witango-talk" in the body.





----------------------------------------


To unsubscribe from this list, please send an email to


[email protected] with "unsubscribe witango-talk" in the body.




--
Robert Garcia
BigHead Technology
15520 Coutelenc Rd
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
[email protected] - http://bighead.net/




----------------------------------------

To unsubscribe from this list, please send an email to [email protected]
with "unsubscribe witango-talk" in the body.



----------------------------------------

To unsubscribe from this list, please send an email to [email protected]
with "unsubscribe witango-talk" in the body.



----------------------------------------

To unsubscribe from this list, please send an email to [email protected]
with "unsubscribe witango-talk" in the body.



----------------------------------------

To unsubscribe from this list, please send an email to [email protected]
with "unsubscribe witango-talk" in the body.





Ben Johansen
http://www.webspinr.com
[email protected]
Phone: 360-597-3372
Mobile: 360-600-7775




  _____

To unsubscribe from this list, please send an email to [email protected]
with "unsubscribe witango-talk" in the body.



  _____

To unsubscribe from this list, please send an email to [email protected]
with "unsubscribe witango-talk" in the body.


--

Robert Garcia

BigHead Technology

15520 Coutelenc Rd

Magalia, Ca 95954

ph: 530.645.4040 x222 fax: 530.645.4040

[email protected] - http://bighead.net/



  _____

To unsubscribe from this list, please send an email to [email protected]
with "unsubscribe witango-talk" in the body.


----------------------------------------

To unsubscribe from this list, please send an email to [email protected] 
with "unsubscribe witango-talk" in the body.

Reply via email to