0

Im using a JQUERY based file uploader and obviously as other file uploaders it posts the data to server. Am using Generic handler to handle the data.

When I use

Context.request.files(0).saveAs(mpath)

It works fine. If its image, it keeps as image in the server keeping all its exif, meta data and everything. Same as if it is any other types, the file doest not loses its basic instinct or content type.

But due to some situational factors Im using Inputstream

So my code is

    Dim inputStream As System.IO.Stream = context.Request.InputStream

    Using fileStream As System.IO.FileStream = System.IO.File.OpenWrite(tempFile)
        inputStream.CopyTo(fileStream)

    End Using

But in this case the files behaves as an unknown file. Loses all its features or content type.

So what I guess is when using inputstream way, it losing its header.. (Not sure thats the reason)

So how can we avoid this and the file to keep all its extra info and type when using Stream

Sandeep Thomas
  • 4,303
  • 14
  • 61
  • 132
  • it's not vb.net but I think this could help you http://stackoverflow.com/questions/2934295/c-sharp-save-a-file-from-a-http-request#2934308 – Elmer Dantas May 19 '17 at 13:41
  • @ElmerDantas Sorry the way in that answer is same as mine expect its for downloading. But it is also using stream.copyto function which results the same – Sandeep Thomas May 19 '17 at 13:50

1 Answers1

0

Sorry..... I found the issue. That was because I was using request.inputstream.

It should be request.file(0).inputstream

Sandeep Thomas
  • 4,303
  • 14
  • 61
  • 132