Upload blob field to SQL Server

ThePuiu

Active Member
Licensed User
Longtime User
Hi, I must upload to a SQL Server a picture located in a blob field on my tablet. On the server should save photo in a blob (image) field too. How can I do that using HttpUtils2? When I tried I got the error message: Request URL Too Long. A picture is about 200K. There is a better way?

TY!

LE:
It seems that would be a problem on the server side. Can you give an example of how it should show page on the server?
 
Last edited:

ThePuiu

Active Member
Licensed User
Longtime User
I changed the project after that example. But... I get the following error: Compiling generated Java code. Error
B4A line: 390
STR = \
javac 1.7.0_13
src\natura2000\mmare\arhiva.java:770: error: no suitable method found for NumberToString(byte[])
_str = "INSERT INTO POZE (ID_OBSERVATIE,TIP,ID_USER,PICTURE) VALUES ("+_id_sql+",'"+_cursor1.GetString("TIP")+"',"+BA.NumberToString(mostCurrent._main._current_user._getuserid())+","+BA.NumberToString(_cursor1.GetBlob("PICTURE"))+")";
^
method BA.NumberToString(long) is not applicable
(actual argument byte[] cannot be converted to long by method invocation conversion)
method BA.NumberToString(int) is not applicable
(actual argument byte[] cannot be converted to int by method invocation conversion)
method BA.NumberToString(double) is not applicable
(actual argument byte[] cannot be converted to double by method invocation conversion)
1 error

used code is:
B4X:
STR = "INSERT INTO POZE (ID_OBSERVATIE,TIP,ID_USER,PICTURE) VALUES (" & ID_SQL & ",'" & Cursor1.GetString("TIP") & "'," & Main.CURRENT_USER.GetUserID & "," & Cursor1.GetBlob("PICTURE") & ")"

If I remove from query the BLOB field, everything works without error.
What should I do?
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
I tried to encode blob field value using su.EncodeBase64 (Cursor1.GetBlob ("photo")) but don't know how to decode it in the aspx page and writed result in the database is wrong for this field.
Or should encode the entire string sent to the aspx page and then decode it before execution?
Thanks for your patience ... now learn!
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
I know how to insert a blob in the database...but unfortunately, in the example that you specified is used HttpUtils.PostString() and I try tu use HttpJob.PostString(). Fail to understand how the two parameters must be formatted. I tried this:
B4X:
URL = "http://android.xxxxx.ro/uploadpoze.aspx?query="
STR = su.EncodeBase64(Cursor1.GetBlob("PICTURE"))
Log("URL:" & URL)
Log("STR:" & STR)
Job.PostString(URL, STR)
but my ASP page returns the message that the query is empty...although in log exists data...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top