Stream large files as a download

54 views
Skip to first unread message

mv10

unread,
Oct 12, 2009, 5:14:06 PM10/12/09
to OpenRasta
I have a URI for which the resource type is some sort of document file
(the specific type can vary... Office files, PDFs, etc). Deriving from
InMemoryFile or InMemoryDownloadableFile is easy enough, but we have
some cases where our clients may be requesting large documents (10MB+
PDFs) that I'd rather not load into a buffer. The files are stored in
a doc repository which isn't accessible via HTTP so I can't just give
them a URL.

Right now I'm just deriving from IFile so I can return a Stream
instead of an in-memory buffer. I'm using FileStream at the moment, I
haven't gone digging yet to see if something else in the process just
buffers it anyway, or if it's truly streamed -- if anybody knows, I'd
appreciate the info. (Based on the response time with some large
files, I'm guessing it's actually streaming.)

What I'd like to do is return an "attachment" Content-Disposition
header like OR does inside InMemoryDownloadableFile to signal that it
should be treated as a download. Some of our users are not necessarily
experienced computer users, so this would be preferable to
instructions about right-clicking and choosing save-as (particularly
with the differences between IE, FF, Chrome, Safari, Windows/Macs,
etc.).

Returning an IFile automatically inserts Content-Disposition of
"inline" ... at what point is this done? Do I need to think about
looking at OR's code and writing my own a stream-based spinoff of
InMemoryDownloadableFile, or is there some easier way to get that
header set up the way I need? Is there anything coming up in OR that
will address this? If so, I can just wait.

Thanks!!

Sebastien Lambla

unread,
Oct 12, 2009, 7:19:54 PM10/12/09
to open...@googlegroups.com
Jut implement IDownloadableFile instead of IFile and you're sorted. The Options don't do anything at the moment.
 
In output, it's streamed (provided you provide the correct content-length beforehand). In input, I have an implementation for full streaming but i won't merge it back till RTM.
 
Seb
 
> Date: Mon, 12 Oct 2009 14:14:06 -0700
> Subject: [openrasta] Stream large files as a download
> From: mcgui...@gmail.com
> To: open...@googlegroups.com

Use Hotmail to send and receive mail from your different email accounts. Find out how.

mv10

unread,
Oct 12, 2009, 10:12:21 PM10/12/09
to OpenRasta
Ah! For some reason I got it into my head that IDownloadableFile was
only a list of settings ... didn't realize it was something I could
use that way (although I should have). Thanks!

On Oct 12, 7:19 pm, Sebastien Lambla <s...@serialseb.com> wrote:
> Jut implement IDownloadableFile instead of IFile and you're sorted. The Options don't do anything at the moment.
>
> In output, it's streamed (provided you provide the correct content-length beforehand). In input, I have an implementation for full streaming but i won't merge it back till RTM.
>
> Seb
>
>
>
> > Date: Mon, 12 Oct 2009 14:14:06 -0700
> > Subject: [openrasta] Stream large files as a download
> > From: mcguire...@gmail.com
> _________________________________________________________________
> Access your other email accounts and manage all your email from one place.http://clk.atdmt.com/UKM/go/167688463/direct/01/
Reply all
Reply to author
Forward
0 new messages