what am trying to do is, upload all text files in a particular directory to a php web service (am using httputils2 version 2.0.1, b4a version 2.00 (yes quite outdated).
am able to upload them but the problem is i get an error after the upload happens.
here's my code below:
i get a log error as shown:
all the files being read correctly and uploaded except for this error message popping up AFTER upload happens.
Any ideas?
am able to upload them but the problem is i get an error after the upload happens.
here's my code below:
B4X:
'Activity module
Sub Process_Globals
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim job_upTxt As HttpJob
Dim l As List
l.Initialize
l = ListFilesOnly(File.DirRootExternal & "/feedback_sys/")
job_upTxt.Initialize("uploadFiles",Me)
For i =0 To l.Size -1
Msgbox(l.Get(i),"")
job_upTxt.PostFile("http://172.17.1.74:8080/uls/index.php?fileName="&l.Get(i)&"",File.DirRootExternal & "/feedback_sys",""&l.Get(i)&"")
Next
End Sub
Public Sub ListFilesOnly(Dir As String) As List
Dim lstDir, lstRes As List
lstRes.Initialize
If File.Exists(Dir, "") Then
lstDir = File.ListFiles(Dir)
Dim FileName As String
For i = 0 To lstDir.Size - 1
FileName = lstDir.Get(i)
If Not(File.IsDirectory(Dir, FileName)) Then
lstRes.Add(FileName)
End If
Next
End If
Return lstRes
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "uploadFiles"
'show the downloaded image
Msgbox("uploaded!","info")
Log(Job.GetString)
End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
i get a log error as shown:
B4X:
LogCat connected to: 20080411413fc082
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Activity (main) Resume **
JobName = uploadFiles, Success = true
<200> upload succeeded
JobName = uploadFiles, Success = true
JobName = uploadFiles, Success = true
<200> upload succeeded
httpjob_getstring2 (B4A line: 105)
tr.Initialize2(File.OpenInput(HttpUtils2Service.TempFolder, taskId), Encoding)
java.io.FileNotFoundException: /data/data/anywheresoftware.b4a.samples.httputils2/cache/3: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:406)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:197)
at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(httpjob.java:272)
at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(httpjob.java:247)
at anywheresoftware.b4a.samples.httputils2.main._jobdone(main.java:348)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:879)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:390)
... 18 more
java.io.FileNotFoundException: /data/data/anywheresoftware.b4a.samples.httputils2/cache/3: open failed: ENOENT (No such file or directory)
all the files being read correctly and uploaded except for this error message popping up AFTER upload happens.
Any ideas?