How to download a stream

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to download a stream

Herbert König
Hi,

my App's results should be downloaded as ASCII files. So I guess I
could create a file and link to it. (haven't tried that)

But I'd like to start a download from a stream. Otherwise I have to
take care about individual filenames and about deleting the files
after download.

So how to start a download and feed it a stream?

Thanks,

Herbert                          mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Returning content of different types (was How to download a stream)

Janko Mivšek
Hi Herbert,

A bit but hope not too late answer:

Returning an answer in a content type other that HTML is actually pretty
simple. Let me explain with example returning an XML:

1. make a new class, say XMLContent as subclass of WebElement
2. ovveride method #aidaContentType to return appropriate content type:

  XMLContent>>aidaContentType
    ^'text/xml'

3. MyApp>>viewAsXml
  | xml |
  xml := '<xml>some XML content</xml>.
  e := XMLContent new.
  e addText: xml.
  ^e

4.in browser open something like:

        http://localhost:8888/myobject?view=asXml

To explain a bit: if App view method return an element with content type
different than default, this content type will be set in a header of
response to your web request. This way we can very simply return content
in any content type we like, like XML, CVS, JPG etc.

I put this explanation on our website in FAQ too:

        http://www.aidaweb.si/faq.html#h-20

Best regards
Janko


On 12. 09. 2010 13:30, Herbert König wrote:

> Hi,
>
> my App's results should be downloaded as ASCII files. So I guess I
> could create a file and link to it. (haven't tried that)
>
> But I'd like to start a download from a stream. Otherwise I have to
> take care about individual filenames and about deleting the files
> after download.
>
> So how to start a download and feed it a stream?
>
> Thanks,
>
> Herbert                          mailto:[hidden email]
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Returning content of different types (was How to download a stream)

Herbert König
Hi Janko,

thanks, it helped. And I found the class comment of WebNonHTMLResource
which explained why my downloads still started with a html extension.


Cheers,

Herbert                            mailto:[hidden email]


JM> Hi Herbert,

JM> A bit but hope not too late answer:

JM> Returning an answer in a content type other that HTML is actually pretty
JM> simple. Let me explain with example returning an XML:

JM> 1. make a new class, say XMLContent as subclass of WebElement
JM> 2. ovveride method #aidaContentType to return appropriate content type:

JM>   XMLContent>>aidaContentType
JM>     ^'text/xml'

3. MyApp>>>viewAsXml
JM>   | xml |
JM>   xml := '<xml>some XML content</xml>.
JM>   e := XMLContent new.
JM>   e addText: xml.
JM>   ^e

JM> 4.in browser open something like:

JM> http://localhost:8888/myobject?view=asXml

JM> To explain a bit: if App view method return an element with content type
JM> different than default, this content type will be set in a header of
JM> response to your web request. This way we can very simply return content
JM> in any content type we like, like XML, CVS, JPG etc.

JM> I put this explanation on our website in FAQ too:

JM> http://www.aidaweb.si/faq.html#h-20

JM> Best regards
JM> Janko




_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida