Sub uploadButton_Click
cam.Initialize("cam",profilePage)
cam.SelectFromSavedPhotos(profilePage.RootPanel,cam.TYPE_IMAGE)
End Sub
Sub cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
If Success Then
If Image.IsInitialized Then
hud.ProgressDialogShow("Uploading photo to BLUF")
Dim boundary As String = "BMU" & BLUF.authKey
Dim EOL As String = Chr(13) & Chr(10)
Log("Boundary is " & boundary)
Log("App key is " & BLUF.loginKey)
Dim form As StringBuilder
form.Initialize
form.Append(EOL).Append("--").Append(boundary).Append(EOL)
form.Append("Content-Disposition: form-data; name=""USERKEY""").Append(EOL).Append(EOL)
form.Append(BLUFsettings.Get("authcode"))
form.Append(EOL).Append("--").Append(boundary).Append(EOL)
form.Append("Content-Disposition: form-data; name=""APPKEY""").Append(EOL).Append(EOL)
form.Append(BLUF.loginKey)
form.Append(EOL).Append("--").Append(boundary).Append(EOL)
form.Append("Content-Disposition: form-data; name=""BLUFupload""; filename=""BLUFuploadTMP.jpg""").Append(EOL)
form.Append("Content-Type: image/jpeg").Append(EOL)
form.Append("Content-Transfer-Encoding: binary").Append(EOL).Append(EOL)
Dim formData() As Byte
formData = form.ToString.GetBytes("UTF8")
Dim formStream As OutputStream
formStream.InitializeToBytesArray(formData.Length)
formStream.WriteBytes(formData,0,formData.Length)
' now formStream has the beginning, add the actual file
Image.WriteToStream(formStream,90,"JPEG")
' put the final boundary on the end of the form
Dim tail As StringBuilder
tail.Initialize
tail.Append(EOL).Append("--").Append(boundary).Append(EOL)
formStream.WriteBytes(tail.ToString.GetBytes("UTF8"),0,tail.Length)
' post to the URL
Log("Form prepared")
Dim uploader As HttpJob
uploader.Initialize("upload",BLUFios)
uploader.PostBytes(BLUF.uploadURL,formStream.ToBytesArray)
uploader.GetRequest.SetContentType("multipart/form-data; boundary=" & boundary)
uploader.GetRequest.SetHeader("User-Agent",BLUF.blufVersion)
End If
End If
End Sub