Hi, I am trying to send a camera captured image to be saved as binary in MS SQL Server.
Then sending it to the server using HTTPRequest
The above codes works for very small images because of limitation on the generated URL length, unfortunately, larger images cannot work and hit error. Is there other alternatives to this? Please advice, thanks.
B4X:
' FOR CONVERTING IMAGE TO STRING SEND OVER THROUGH WEB SERVICE
Dim str64Pic As String
If strPhotoSnapName <> "" Then
Dim in As InputStream
Dim out As OutputStream
in = File.OpenInput(File.DirRootExternal, strPhotoSnapName)
out.InitializeToBytesArray(0)
File.Copy2(in, out)
Dim data() As Byte
data = out.ToBytesArray
Dim b64 As Base64
b64.BreakLines = True
b64.UrlSafe = True
b64.LineLength = 75
str64Pic = b64.EncodeBtoS(data,0,data.Length)
str64Pic = strStringUtils.EncodeUrl(str64Pic, "UTF8")
End If
Then sending it to the server using HTTPRequest
B4X:
Dim request As HttpRequest
request.InitializeGet("http://8.8.8........./default.aspx?image=" & str64Pic)
request.Timeout = 10000 'set timeout to 10 seconds
If HttpClientAccess.Execute(request, 5) = False Then Return
ProgressDialogShow("Processing...")
The above codes works for very small images because of limitation on the generated URL length, unfortunately, larger images cannot work and hit error. Is there other alternatives to this? Please advice, thanks.