Android Question java.lang.ClassCastException in PostMultiPart

Marco Maria Vilucchi

Active Member
Licensed User
Longtime User
Hi all,
I'm trying to send a file via PostMultiPart (I can't use FTP)

I sue this code:

B4X:
Dim j As HttpJob
j.PostMultipart(Main.ServerUrl, NV, files)
Wait for (j) JobDone(Response As HttpJob)
If Response.Success Then ' hc_ResponseSuccess
    Log ("Risposta: " &Response.GetString)
    Msgbox(Response.GetString, "")
Else ' hc_ResponseError, but without StatusCode
    Log("Error : " & Response.ErrorMessage)
End If

Params value are:
B4X:
Main.ServerUrl http://www.webfitness.it/web-fitness/app_query.php
NV (MyMap) {id_associazione =1, matricola=230144, data_nizio_certificato=23014420180419certificato.jpg}
files (ArrayList) [[ContentType=application/octet-stream, Dir=/storage/emulated/0/Android/data/com.mamavi.webfitness/files, FileName=23014420180419certificato.jpg
, KeyName=upfilecert, IsInitialized=true]]

I have this error:
B4X:
Error occurred on line: 198 (Certificato)
java.lang.ClassCastException: com.mamavi.webfitness.multipartpost$_filedata cannot be cast to anywheresoftware.b4a.samples.httputils2.httpjob$_multipartfiledata
    at anywheresoftware.b4a.samples.httputils2.httpjob._postmultipart(httpjob.java:383)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)

The file exists.
I think error is in "files", because if i send without files I have no error
B4X:
j.PostMultipart(Main.ServerUrl, NV, Null)
But so I can't send the file.....

Someone can help me?
Thanks
Marco
 

OliverA

Expert
Licensed User
Longtime User
Upvote 0
Top