我是CURL的新手,想知道如何使用httpWebRequest将以下命令转换为.net(这是我的猜测)
curl -X POST http://127.0.0.1:8042/instances --data-binary @CT.X.1.2.276.0.7230010.dcm
我真的没有尝试过任何事情,坦白说我不知道从哪里开始。
答案 0 :(得分:0)
以下是我根据@ M.Hassan发布的示例提出的内容
Public Function UPLOAD_FILE(filepath As String) As String
Dim request As WebRequest = WebRequest.Create("http://localhost:8042/instances ")
request.Method = "POST"
Dim byteArray As Byte() = File.ReadAllBytes(filepath)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
Console.WriteLine((CType(response, HttpWebResponse)).StatusDescription)
dataStream = response.GetResponseStream()
Dim reader As StreamReader = New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
Return responseFromServer
End Function