Bueno por el momento logre esto:
Código vb:
Ver originalPrivate Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
Dim address As Uri
Dim data As StringBuilder
Dim byteData() As Byte
Dim postStream As Stream = Nothing
Dim username As String
Dim password As String
Dim file_location As String
Dim tags As String
Dim source As String
Dim md5 As String
address = New Uri("http://localhost/api/add_image")
' Create the web request
request = DirectCast(WebRequest.Create(address), HttpWebRequest)
' Set type to POST
request.Method = "POST"
request.ContentType = "multipart/form-data"
' Create the data we want to send
username = "user"
password = "userpass"
file_location = txtFile.Text
tags = "coco nu_se"
source = "http://www.seinkraft.info"
md5 = "2ef87d61eb6c5d318760db51828d8d00"
data = New StringBuilder()
data.Append("login=" + username)
data.Append("&password=" + password)
data.Append("&file=" + file_location)
data.Append("&md5=" + md5)
data.Append("&tags=" + tags)
data.Append("&source=" + source)
TextBox1.Text = data.ToString
' Create a byte array of the data we want to send
byteData = UTF8Encoding.UTF8.GetBytes(data.ToString())
' Set the content length in the request headers
request.ContentLength = byteData.Length
' Write data
Try
postStream = request.GetRequestStream()
postStream.Write(byteData, 0, byteData.Length)
Finally
If Not postStream Is Nothing Then postStream.Close()
End Try
Try
' Get response
response = DirectCast(request.GetResponse(), HttpWebResponse)
' Get the response stream into a reader
reader = New StreamReader(response.GetResponseStream())
' Console application output
TextBox2.Text = reader.ReadToEnd()
Finally
If Not response Is Nothing Then response.Close()
End Try
End Sub
Y los parametros de la api son:
Parameters
* login: login
* password: password
* file: file as a multipart form
* source: source url
* tags: list of tags as a string, delimited by whitespace
* md5: MD5 hash of upload in hexadecimal format
Lo que no se es como hacer la parte del file (ahora esta echa asi nomas). No se como enviarlo como multipart
Alguien me puede ayudar con ello?