Seaside Book: Chapter 17, Serving Files

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

Seaside Book: Chapter 17, Serving Files

Schwab,Wilhelm K
Stef,

Thanks for Dynamic Web Development With Seaside - it's a great book!  One omission that I have noted is that of dynamically serving files. 

Making a long story short, I have a Seaside app that swallows and regurgitates literature (300 MB and growing).  It is what has me interested in Citezen (which is working wonderfully - thanks again!).  I wish I had known more about Seaside when I started to write it, but it is slowly improving.  Clearly, I can't put hundreds of megabytes in a FileLibrary, and I have no interest in configuring a static web server for something that (sadly or not) runs locally on multiple machines, with data synchronized via what amounts to an rsynch clone and ever-growing flash sticks.

The answer is to serve the content dynamically, as below.  I think this technique deserves mention in Chapter 17.

Bill


serveFileNamed:fileName for:component canvas:html

        | mimeType |


    ( File splitExtensionFrom:fileName ) = 'pdf' ifTrue:[ mimeType := 'application/pdf' ].
    ( File splitExtensionFrom:fileName ) = 'txt' ifTrue:[ mimeType := 'application/text' ].
    ( File splitExtensionFrom:fileName ) = 'gz' ifTrue:[ mimeType := 'application/x-gzip' ].

    component session requestContext respond:[ :response |
        response
            document:self fullTextAsString
            mimeType:mimeType
            fileName:fileName;
            doNotCache
    ]



Reply | Threaded
Open this post in threaded view
|

Re: Seaside Book: Chapter 17, Serving Files

fstephany
Hi Bill,

I probably miss something in the use case but why don't you simply serve
that static content with Kom or Zinc ?


On 25/03/12 18:29, Schwab,Wilhelm K wrote:
> Clearly, I can't put hundreds of megabytes in a FileLibrary, and I have
> no interest in configuring a static web server for something that (sadly
> or not) runs locally on multiple machines, with data synchronized via
> what amounts to an rsynch clone and ever-growing flash sticks.

Reply | Threaded
Open this post in threaded view
|

Re: Seaside Book: Chapter 17, Serving Files

Schwab,Wilhelm K
Francois,

I am probably missing something too<g>, but dynamically serving the documents is EASY, and that message should get out.  The app in question originally ran on a server.  At first, that was a way to get around my lack (at the time) of good file synchronizing on Linux - I have long since ported to Pharo a tool that I have use for years so that it runs on Linux.  That makes it easy to move files from one machine to another (basically between desktop and laptop).

Having the system on a server offered the option for others to see the data, but they never used it.  IT policies became problematic (or at least scary), and it is simply easier for to run it locally, so I took that plunge.  The system has security features that make little sense now; I might remove them some day.

When it ran on a server, I simply generated urls for the full text articles.  At present, serving the files dynamically "just works" and does it w/o the need to think about servers and URLs.  It is a nice solution that I think deserves mention along with FileLibrary and other methods.

Bill



________________________________________
From: [hidden email] [[hidden email]] on behalf of Francois Stephany [[hidden email]]
Sent: Sunday, March 25, 2012 11:23 PM
To: [hidden email]
Subject: Re: [Pharo-project] Seaside Book: Chapter 17, Serving Files

Hi Bill,

I probably miss something in the use case but why don't you simply serve
that static content with Kom or Zinc ?


On 25/03/12 18:29, Schwab,Wilhelm K wrote:
> Clearly, I can't put hundreds of megabytes in a FileLibrary, and I have
> no interest in configuring a static web server for something that (sadly
> or not) runs locally on multiple machines, with data synchronized via
> what amounts to an rsynch clone and ever-growing flash sticks.


Reply | Threaded
Open this post in threaded view
|

Re: Seaside Book: Chapter 17, Serving Files

fstephany
Yep it works well and if it fits your needs then go for it ;)

I serve static assets with Seaside when the files are only accessible
for a logged in user or when it depends of the state of the sessions.

In other cases, I simply put all my files in a directory next to the
image and serve them with Zinc/Kom when I develop

On 25/03/12 20:55, Schwab,Wilhelm K wrote:

> Francois,
>
> I am probably missing something too<g>, but dynamically serving the documents is EASY, and that message should get out.  The app in question originally ran on a server.  At first, that was a way to get around my lack (at the time) of good file synchronizing on Linux - I have long since ported to Pharo a tool that I have use for years so that it runs on Linux.  That makes it easy to move files from one machine to another (basically between desktop and laptop).
>
> Having the system on a server offered the option for others to see the data, but they never used it.  IT policies became problematic (or at least scary), and it is simply easier for to run it locally, so I took that plunge.  The system has security features that make little sense now; I might remove them some day.
>
> When it ran on a server, I simply generated urls for the full text articles.  At present, serving the files dynamically "just works" and does it w/o the need to think about servers and URLs.  It is a nice solution that I think deserves mention along with FileLibrary and other methods.
>
> Bill
>
>
>
> ________________________________________
> From: [hidden email] [[hidden email]] on behalf of Francois Stephany [[hidden email]]
> Sent: Sunday, March 25, 2012 11:23 PM
> To: [hidden email]
> Subject: Re: [Pharo-project] Seaside Book: Chapter 17, Serving Files
>
> Hi Bill,
>
> I probably miss something in the use case but why don't you simply serve
> that static content with Kom or Zinc ?
>
>
> On 25/03/12 18:29, Schwab,Wilhelm K wrote:
>> Clearly, I can't put hundreds of megabytes in a FileLibrary, and I have
>> no interest in configuring a static web server for something that (sadly
>> or not) runs locally on multiple machines, with data synchronized via
>> what amounts to an rsynch clone and ever-growing flash sticks.
>
>

--
http://tulipemoutarde.be
CA: +1 778 558 3225
BE: +32 65 709 131

Reply | Threaded
Open this post in threaded view
|

Re: Seaside Book: Chapter 17, Serving Files

Philippe Marschall-2
In reply to this post by Schwab,Wilhelm K
On 03/26/2012 03:29 AM, Schwab,Wilhelm K wrote:
> Stef,
>
> Thanks for Dynamic Web Development With Seaside - it's a great book!  One omission that I have noted is that of dynamically serving files.
>
> Making a long story short, I have a Seaside app that swallows and regurgitates literature (300 MB and growing).  It is what has me interested in Citezen (which is working wonderfully - thanks again!).  I wish I had known more about Seaside when I started to write it, but it is slowly improving.  Clearly, I can't put hundreds of megabytes in a FileLibrary, and I have no interest in configuring a static web server for something that (sadly or not) runs locally on multiple machines, with data synchronized via what amounts to an rsynch clone and ever-growing flash sticks.

It's hard to describe how much better Apache is at serving static files
than Seaside/Pharo. The stability, performance, scalability, efficiency,
it's from an other world.

Cheers
Philippe