Android Question Uploading file using httputils2

alon

Active Member
Licensed User
Longtime User
Hi,
I am using httputils2 for updating sql data base throw a web service.
I am using PostString with url including parameters which runs store procedures in the sql server.

now what I am trying to do is to send binary data (image file) as a parameter url, and the parameter will be transferred to the sql store procedure .
the store procedure will save the image (binary data) in the sql table.
is it possible to it using httputils2.

Thanks in advance
 

KMatle

Expert
Licensed User
Longtime User
Yep. I prefer this:

B4X:
Dim FileBuffer(0) As Byte
FileBuffer=Bit.InputStreamToBytes(File.OpenInput(FilePath,FileName))

    Dim B64String As String
    Dim su As StringUtils
    B64String=su.EncodeBase64(FileBuffer)

In the MySQL db define a field as longtext and store it (=B64String) as a normal string.
 
Upvote 0

alon

Active Member
Licensed User
Longtime User



Thank you very much for your help,
I was trying to that using httputils2 library and i am getting this error massage:
Message longer than Log limit (4000). Message was truncated.

what should I do?
Thanks
 
Upvote 0

alon

Active Member
Licensed User
Longtime User
it is not me who is writing the log , it is build in the library.
and the command failed because of that .
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
it is not me who is writing the log , it is build in the library.
In which library? Not in okhttputils2 i´m sure...

Upload your project. Without seeing your code we just can guess what you are doing.
okhttputils lib itself does not do any log-output.

Most probably it is inside YOUR JobDone-Event.
 
Upvote 0

alon

Active Member
Licensed User
Longtime User
In which library? Not in okhttputils2 i´m sure...

Upload your project. Without seeing your code we just can guess what you are doing.
okhttputils lib itself does not do any log-output.

Most probably it is inside YOUR JobDone-Event.

I am using httputils2 and not okhttputils
 
Upvote 0

alon

Active Member
Licensed User
Longtime User
Please use the "NEW" OkHttp & OkHttpUtils (no change, just use the new libs)

Usually there is a "LOG (res)"
I am trying to do that but I am getting error for command time out:
job.GetRequest.Timeout =DateTime.TicksPerSecond * 30

what is the command for timeout in OkHttpUtils library.?
Please use the "NEW" OkHttp & OkHttpUtils (no change, just use the new libs)

Usually there is a "LOG (res)"

Thanks work greate
 
Upvote 0

alon

Active Member
Licensed User
Longtime User

hi ,
after saving the B64String in my sql database , in a varchar(max) field (lontext),
I am trying to make an image file out of it, but the image cannot be display.
I also tried to convert the value to an image field but still having the same problem.

thanks
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Here:

B4X:
Dim FileBytes() As Byte
Dim su As StringUtils
FileBytes=su.DecodeBase64(B64String) 'B64String is coming from Job.Done (Job.GetString or from a JSON - depends on how you send it back)

Dim In As InputStream
In.InitializeFromBytesArray(FileBytes, 0, FileBytes.Length)
Dim bmp As Bitmap
bmp.Initialize2(In)
 
Upvote 0

alon

Active Member
Licensed User
Longtime User

Thank you very much for your help, i wat trying to get the image to a pc and not to my cell.
but thanks to your answer I figure out my problem.

So many thanks again.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…