Here is an example. The function ReadBinaryFile is a function in the same object that uses FileOpen/FileReadEx/FileClose to read the file into a blob.
HttpClient lnv_Http
Constant Long BlobPartLen = 65536
Blob lblb_PostData, lblb_PostPart
Integer li_rc, li_PartNum
Long ll_StatusCode, ll_Bytes
String ls_ServerURL, ls_RecvData
String ls_PathName, ls_FileName, ls_StatusText
li_rc = GetFileOpenName("Select a File", ls_PathName, ls_FileName)
If li_rc < 1 Then Return
mle_response.Text = ""
cb_openfile.Enabled = False
FileDelete(is_FileName)
Yield()
SetPointer(HourGlass!)
// read the file
ll_Bytes = ReadBinaryFile(ls_PathName, lblb_PostData)
If ll_Bytes = 0 Then
MessageBox(this.Text, &
"ReadBinaryFile Failed!", StopSign!)
Return
End If
// set the URL
ls_ServerURL = "http://localhost/pbhttp/webservice.pbh"
// create the object
lnv_Http = Create HttpClient
// set headers
lnv_Http.SetRequestHeader("FileName", ls_FileName)
lnv_Http.SetRequestHeader("Content-Length", String(Len(lblb_PostData)))
// send the request
li_rc = lnv_Http.PostDataStart(ls_ServerURL)
If li_rc = 1 Then
// post the data in parts
do while li_rc = 1
lblb_PostPart = BlobMid(lblb_PostData, li_PartNum * BlobPartLen + 1, BlobPartLen)
li_rc = lnv_Http.PostData(lblb_PostPart, BlobPartLen)
li_PartNum ++
loop
lnv_Http.PostDataEnd()
// get results
ll_StatusCode = lnv_Http.GetResponseStatusCode()
If ll_StatusCode = 200 Then
// HTTP status 200 = OK
lnv_Http.GetResponseBody(ls_RecvData)
mle_response.text = ls_RecvData
Else
lnv_Http.GetResponseBody(ls_RecvData)
mle_response.text = ls_RecvData
ls_StatusText = lnv_Http.GetResponseStatusText()
MessageBox("SendRequest Error #" + String(ll_StatusCode), &
ls_StatusText, StopSign!)
End If
Else
MessageBox(this.Text, &
"PostDataStart Error: " + String(li_rc), StopSign!)
End If
// destroy the object
Destroy lnv_Http
Now I can upload the file successfully...
This boundary value got from Postman...
Actually what is the meaning of this value ?