0

I am a newbie to VB.net and web services in general. I am working on designing a feature that ,

i.Accepts a document (Content-type : multipart/related) from outside.(Parameterized input to my code maybe ?)

ii.Does a call on a web service to submit that to a cloud server (eg. maybe amazon , maybe something else)

I want to know where to start with this, i want to create a small vb.net project first that accepts as input some (multipart/related form based document) and does a call(post) on a web service that sends out that data to the cloud. How are these multipart documents posted ?

Edit :

The web service API i am working on will have a WebMethod that will accept a file (xml/json) as input and create a multipart/related document and then post it to a web service. i did see posts here that work with creating multipart/form-data but am not sure if the way to create a multpart/related document will be the same because multipart/related documents work with compound documents.

Ref: Upload files with HTTPWebrequest (multipart/form-data)

Community
  • 1
  • 1
Som Bhattacharyya
  • 3,972
  • 35
  • 54

1 Answers1

1
  1. From this question, your HTML might look something like this:

    <form id="uploadbanner" enctype="multipart/form-data" method="post" action="#">
        <input id="fileupload" name="myfile" type="file" />
        <input type="submit" value="submit" id="submit" />
    </form>
    
  2. From here, this server side code may get you started:

    Dim savedFile As String
    savedFile = Path.GetFileName(Me.fileUpload.PostedFile.FileName)
    Me.fileUpload.PostedFile.SaveAs(Server.MapPath("cvs\"))
    
  3. "Submit[ting] to a cloud server" is going to be completely dependent on which service you use. You'll have to choose one first, and I'd be willing to bet they have some kind of API with examples to help you use their service. In addition, there are probably great examples here on StackOverflow to get you going. The search function can be a great help when you're ready.

Community
  • 1
  • 1
Justin Ryan
  • 1,409
  • 1
  • 12
  • 25
  • Okay so will anything change in 1. and 2. if the content type is "multipart/related" ? – Som Bhattacharyya Oct 12 '14 at 18:53
  • I expect that you're going to encounter problems with your web server when trying to upload anything without using "multipart/form-data". Remember, this enctype refers to the HTML form data being returned from your web page, not the enctype of the file you're trying to upload. – Justin Ryan Oct 12 '14 at 19:09
  • If you really need to get your hands dirty, here's the Relevant part of the [HTML spec](http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4). The browser generally takes care of all these details for you. – Justin Ryan Oct 12 '14 at 19:19
  • So i need to use asp.NET for this kind of feature ? Also i am still waiting on clarification on how i will receive the form data that i will be posting to the cloud service. Will discuss with you once i know it. Thanks. – Som Bhattacharyya Oct 13 '14 at 03:58
  • You don't _need_ to use ASP.Net, you can accept uploads with any popular server side scripting language. I assumed you were using ASP.Net because you tagged your question with, and used the term VB.Net in your question. For example, PHP could handle uploading duties just as well. – Justin Ryan Oct 13 '14 at 05:15
  • So yeah now the requirement is a bit different.The web service API i will be working on will accept a file (xml/json) as input and create a multipart/related document and then post it to a web service. i did see posts here that work with creating multip[art/form-data but am not sure if the way to create a multpart/related document will be the same. Ref: http://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data?answertab=votes#tab-top – Som Bhattacharyya Oct 17 '14 at 07:17