ASP FileUpload InputStream and System.IO.File.OpenRead

c#, file-upload, rackspace

Solution

Normally `PostedFile.InputStream` and `System.IO.Stream` are same. So there is no need of any additional coding for Rackspace.

You can use file.InputStream as the Stream parameter to create the Object of Rackspace cloud files.

Another method which is not required but can test is

byte[] buffer = new byte[file.InputStream.Length];
file.InputStream.Seek(0, SeekOrigin.Begin);
file.InputStream.Read(buffer, 0, Convert.ToInt32(file.InputStream.Length));
Stream stream2 = new MemoryStream(buffer);

You can use this stream also as input for creating object.

Problem

I have an ASP File upload, `PostedFile.InputStream`, it is giving us the `System.IO.Stream`. Is this file stream similar to that of getting ``` System.IO.File.OpenRead("filename"); ``` I have a Rackspace file content saver that gets the input as Stream, it's not getting the correct image displayed when used `PostedFile.InputStream`.

Original source