Re: Include binary files in template/XML (SOLVED/Request new

This WebDNA talk-list message is from

2004


It keeps the original formatting.
numero = 59770
interpreted = N
texte = Make sure that you have the WebDNA version with the bug fix or IT WON'T WORK. On 27/10/2004, at 10:57 AM, Sal D'Anna wrote: > New for WebDNA 5.1" - 'BinaryBody' option: > > > [ReturnRaw binarybody=...] > Allows the WebDNA programmer to designate a file (binary or text) to be > attached as the 'body' of an HTTP response. This makes it possible to > send a > binary file (image, executable, etc...) back to the client. For > example, you > can create download links for any type of file, and that would force > the > 'save as' dialog to open on the client machine. > > > Example code: Creates a download link for every file in the current > folder, > binary or text. > > > > > > [!]Initailize the getfile variable[/!] > [text secure=f]getfile=[/text] > > [!]Check if filename was passed in[/!] > [showif [getfile]!] > [text]line_ending=%0D%0A[/text] > > [!]Generate the response[/!] > [ReturnRaw binarybody=[getfile]]HTTP/1.0 200 > OK[unurl][line_ending][/unurl][!] > [/!]Status: 200[unurl][line_ending][/unurl][!] > [/!]Content-Type: > application/octet-stream[unurl][line_ending][/unurl][!] > [/!]Content-Disposition: attachment; > filename="[getfile]"[unurl][line_ending][line_ending][/unurl][!] > [/!][/ReturnRaw] > > [/showif] > > [!] Generate a list of download links for all files in local directory > [/!] > Click on a filename to download.

> [listfiles path=.] > [showif [isfile]=T] > [filename]
> [/showif] > [/listfiles] > > > > > -----Original Message----- > From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf Of > Morten Madsen > Sent: Tuesday, October 26, 2004 7:24 AM > To: WebDNA Talk > Subject: Re: Include binary files in template/XML (SOLVED/Request new > feature) > > Hi. > I found a solution for my problem (problem: read below). > > Instead of [include] i used [TcpConnect] to our own server (localhost) > - > used the GET command on the requsted file, encrypted til data with > base64 and saved it in a textvar. > > ********************************* CODE EXAMPLE > ************************************************ > [text]host=yourhost.com[/text] > [text]filename=filename.jpg[/text] > [text]path=/path/to/file/[filename][/text] > > [TCPConnect host=[host]&port=80] > [text]binary_encoded_data=[Encrypt method=base64][TCPSend > skipheader=T]GET [path] HTTP/1.0[UnURL]%0D%0A[/UnURL] > Host: [host][unurl]%0D%0A%0D%0A[/unurl] > [/TCPSend][/Encrypt][/text] > [/TCPConnect] > > Result Binary (base64 encoded) data here: [binary_encoded_data] > ********************************* /CODE EXAMPLE > ************************************************ > > BUT it would be alot better/easier if one could get binary files with > the use of [include]. It would be like this [include > file=binaryfile.jpg&raw=T&binary=T] > > Hope Smith Micro will consider this feature in a future release.... > > Kind Regards > Morten > > > -----Original Message----- > From: Morten Madsen > Sent: 26. oktober 2004 13:35 > To: WebDNA Talk > Subject: Include binary files in template/XML > > > Hi > > I have a problem - I need to generate a XML-file with image-files > included in the XML tags. > > At first i did not think it would be any problem - my plan was to use > [write file] with the XML tags and information from the database. And > in > the image-tag I planned on using [include file=...&raw=t] and [encrypt > method=base64] - but sadly the include can't read the file - because > the > file is a binary file - and not a text file. > > Example: > [Encrypt method=base64][include file=image.jpg&raw=t][/Encrypt] > I would like this to return the data-stream from from the file - base64 > encoded. > > > Honestly I really don't know much about this subject - Have anybody > made > Webcat read binary files? Is it posible at all? > > I found a way to do it using .NET: > http://www.perfectxml.com/Answers.asp?ID=2 > > But since our system uses Webcatalog - i would prefer making a solution > i webdna. > > > Hope you guys can help me... > Kind Regards > Morten Madsen > > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://webdna.smithmicro.com/ > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://webdna.smithmicro.com/ > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://webdna.smithmicro.com/ > > Regards Stuart Tremain idfk web developments 114a/40 yeo street neutral bay 2089 australia t +612 9908 2134 f +612 9908 4837 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Include binary files in template/XML (SOLVED/Request new ( Stuart Tremain 2004)
  2. Re: Include binary files in template/XML (SOLVED/Request new ( "Sal D'Anna" 2004)
  3. Re: Include binary files in template/XML (SOLVED/Request new ( "Morten Madsen" 2004)
Make sure that you have the WebDNA version with the bug fix or IT WON'T WORK. On 27/10/2004, at 10:57 AM, Sal D'Anna wrote: > New for WebDNA 5.1" - 'BinaryBody' option: > > > [ReturnRaw binarybody=...] > Allows the WebDNA programmer to designate a file (binary or text) to be > attached as the 'body' of an HTTP response. This makes it possible to > send a > binary file (image, executable, etc...) back to the client. For > example, you > can create download links for any type of file, and that would force > the > 'save as' dialog to open on the client machine. > > > Example code: Creates a download link for every file in the current > folder, > binary or text. > > > > > > [!]Initailize the getfile variable[/!] > [text secure=f]getfile=[/text] > > [!]Check if filename was passed in[/!] > [showif [getfile]!] > [text]line_ending=%0D%0A[/text] > > [!]Generate the response[/!] > [ReturnRaw binarybody=[getfile]]HTTP/1.0 200 > OK[unurl][line_ending][/unurl][!] > [/!]Status: 200[unurl][line_ending][/unurl][!] > [/!]Content-Type: > application/octet-stream[unurl][line_ending][/unurl][!] > [/!]Content-Disposition: attachment; > filename="[getfile]"[unurl][line_ending][line_ending][/unurl][!] > [/!][/ReturnRaw] > > [/showif] > > [!] Generate a list of download links for all files in local directory > [/!] > Click on a filename to download.

> [listfiles path=.] > [showif [isfile]=T] > [thisurl]?getfile=[url][filename][/url]>[filename]
> [/showif] > [/listfiles] > > > > > -----Original Message----- > From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf Of > Morten Madsen > Sent: Tuesday, October 26, 2004 7:24 AM > To: WebDNA Talk > Subject: Re: Include binary files in template/XML (SOLVED/Request new > feature) > > Hi. > I found a solution for my problem (problem: read below). > > Instead of [include] i used [tcpconnect] to our own server (localhost) > - > used the GET command on the requsted file, encrypted til data with > base64 and saved it in a textvar. > > ********************************* CODE EXAMPLE > ************************************************ > [text]host=yourhost.com[/text] > [text]filename=filename.jpg[/text] > [text]path=/path/to/file/[filename][/text] > > [TCPConnect host=[host]&port=80] > [text]binary_encoded_data=[Encrypt method=base64][TCPSend > skipheader=T]GET [path] HTTP/1.0[unurl]%0D%0A[/UnURL] > Host: [host][unurl]%0D%0A%0D%0A[/unurl] > [/TCPSend][/Encrypt][/text] > [/TCPConnect] > > Result Binary (base64 encoded) data here: [binary_encoded_data] > ********************************* /CODE EXAMPLE > ************************************************ > > BUT it would be alot better/easier if one could get binary files with > the use of [include]. It would be like this [include > file=binaryfile.jpg&raw=T&binary=T] > > Hope Smith Micro will consider this feature in a future release.... > > Kind Regards > Morten > > > -----Original Message----- > From: Morten Madsen > Sent: 26. oktober 2004 13:35 > To: WebDNA Talk > Subject: Include binary files in template/XML > > > Hi > > I have a problem - I need to generate a XML-file with image-files > included in the XML tags. > > At first i did not think it would be any problem - my plan was to use > [write file] with the XML tags and information from the database. And > in > the image-tag I planned on using [include file=...&raw=t] and [encrypt > method=base64] - but sadly the include can't read the file - because > the > file is a binary file - and not a text file. > > Example: > [Encrypt method=base64][include file=image.jpg&raw=t][/Encrypt] > I would like this to return the data-stream from from the file - base64 > encoded. > > > Honestly I really don't know much about this subject - Have anybody > made > Webcat read binary files? Is it posible at all? > > I found a way to do it using .NET: > http://www.perfectxml.com/Answers.asp?ID=2 > > But since our system uses Webcatalog - i would prefer making a solution > i webdna. > > > Hope you guys can help me... > Kind Regards > Morten Madsen > > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://webdna.smithmicro.com/ > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://webdna.smithmicro.com/ > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://webdna.smithmicro.com/ > > Regards Stuart Tremain idfk web developments 114a/40 yeo street neutral bay 2089 australia t +612 9908 2134 f +612 9908 4837 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Stuart Tremain

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

can WC render sites out? (1997) Virtual hosting and webcatNT (1997) Error: this shopping cart has already been submitted and been (2006) protect tag on NT IIS (1997) Passing a search through a form (2003) [ShowIf] and empty fields (1997) Locking up with WebCatalog... (1997) Using Plug-In while running 1.6.1 (1997) ADMIN ACCESS (1999) b12 cannot limit records returned and more. (1997) WCf2 and nested tags (1997) Summing fields (1997) command=purchase (2000) [WebDNA] TCPConnect example doesn't work (2017) sorting... (2003) [WebDNA] Multiple e-mail sending (2011) What am I missing (1997) RE: Adding headers to email (1997) [WebDNA] WebDNA & Google Chrome Browser (2012) Moment of Thanks (1997)