Hi, I have a lot of files to download, I had these in a zip, downloaded and extracted the zip. this works fine! however these files in my case images (but i dont want to restrict this question to images so they are FILES!) the zip has grown in size and is now around 120meg! as the images change this downloads everytime you run the app! So im looking to download a list of files (I can check sizes, and if they exist prior to doing this thats not the problem!)
I have a list of files stored in a list. (these are just the file names) so I can submit a job and add the url & the filename from the list.
I need the filename to be saved in each case. so a file called file1.jpg must be saved as file1.jpg and so on.
The code I tried was this - but it crashes
I get an error - immediately like so
httpjob_vvvvvvvvv0 (java line: 138)
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.aidymp.aidymatic/files/54: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209)
at com.aidymp.aidymatic.httpjob._vvvvvvvvv0(httpjob.java:138)
at com.aidymp.aidymatic.main._jobdone(main.java:4143)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 16 more
What could be the problem?
Thanks
Aidy
I have a list of files stored in a list. (these are just the file names) so I can submit a job and add the url & the filename from the list.
I need the filename to be saved in each case. so a file called file1.jpg must be saved as file1.jpg and so on.
The code I tried was this - but it crashes
B4X:
For a = 0 To ListOfImages.Size-1
LogColor(ListOfFiles.Get(a),Colors.Blue)
Dim Job As HttpJob
Job.Initialize("file", Me)
JobsIndex.Put(Job, a)
Job.Download("http://test.com/apps/"&ListOfFiles.Get(a))
Next
Sub JobDone (Job As HttpJob)
Log("Job "&Job.JobName)
If Job.JobName = "file" Then
Dim index As Int = JobsIndex.Get(Job) 'find the index of the job
Log(ListOfFiles.Get(index))
Dim o As OutputStream
o = File.OpenOutput(File.DirDefaultExternal,ListOfFiles.Get(index) , False)
File.Copy2(Job.GetInputStream, o)
o.Close
Return
End If
...
end sub
I get an error - immediately like so
httpjob_vvvvvvvvv0 (java line: 138)
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.aidymp.aidymatic/files/54: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209)
at com.aidymp.aidymatic.httpjob._vvvvvvvvv0(httpjob.java:138)
at com.aidymp.aidymatic.main._jobdone(main.java:4143)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 16 more
What could be the problem?
Thanks
Aidy