-1

a little background on our system, we have a mvc application that creates and displays forms, then posts these forms to a controller within the mvc application. it then does verification etc. etc.

I want to be able to use this to upload a file (currently using a post with the contoller pulling out the httppostedfilebase) have it send that file to a seperate application API which will pull the file information, store the information in the database, and save the file as something generic.

I have a method that can do all the pull apart/save file stuff, I have a controller that accepts my form post and gets all the relevant data including an httppostedfilebase. What I need is a way to send that file (which is not saved yet) over to our API.

We are hoping to avoid turning the file into a base64 string.

This is in c#.

Drew Major
  • 501
  • 1
  • 3
  • 18
  • We don't provide tutorials, I'm afraid. Show us what you've tried. – emerson.marini May 11 '15 at 20:23
  • I'm not exactly sure what to try. I looked into encoding the file into a base64 string to send to the api and then turn back into a file, but have read that it can inflate the size of the file. I wanted to get some input of different methods to transfer a file without saving it, turning it into a string, etc. Just some pointers on what to look for. – Drew Major May 11 '15 at 20:51

2 Answers2

0

Have you looked at this answer: Web API: how to access multipart form values when using MultipartMemoryStreamProvider?

I think it will provide some ideas on how to handle streaming files in memory.

Community
  • 1
  • 1
Karen B
  • 331
  • 2
  • 9
0

Solution we used:

using HttpPostedFileBase from the multipart form, create byte array stream file contents into the byte array convert byte array to base64 string add to json object along with file headers (name and extension) post json object to api using HttpClient

Drew Major
  • 501
  • 1
  • 3
  • 18