views:

570

answers:

1

When is PostedFile.InputStream available when uploading a large file?

I'd like to pass a Stream to another process and I'm hoping that if a large file was being uploaded that I can pass the Stream straight to that new process w/o writing to the file system. Since the process and/or upload could take a while, I'm wondering if I can start reading the InputStream immediately or whether I have to wait for the whole file to be transferred to the server before it can be processed.

I guess a more general question is - what's the lifecycle of a POST request when file upload is involved?

+1  A: 

The PostedFile.InputStream isn't available until the entire file has been uploaded. IIS6 caches the file in memory while IIS7 now caches the file to disk before handing off the input stream to your method.

You can get a HttpModule such as NeatUpload which allows you access to the bits while they're uploading.

Todd Smith