B4A Class Dropbox API V2. All HTTP! All using httputils2

RafaelC

Member
Licensed User
Don,
Ok. I'll go once more around this post. Of course I did it before (not only this post but several other in the forum). But I'll try again

No; Of course I am not using both ICR1 and ICR2 on the same App. I just tried it compiling everytime a different App.

Thank you for your comments
 

RafaelC

Member
Licensed User
Thanks. I am downloading to the external SDCard. And they download well when I use the Dropbox Generated Token. I understood that it was only allowed to write to the subfolders of your App in the SDCard. Maybe I was wrong.
 

DonManfred

Expert
Licensed User
BTW: Have you seen this? https://www.b4x.com/android/forum/threads/beta-dropbox-sdk-v2-java.74019/

This is a complete new wrapper for the java dropbox sdk V2...

It is not finished as of now (but it will be finished this year i guess) but you already can do a lot of things. Even Up- and downloading. But most of the methods are not tested as of now. Just did the coding so far in the last days...

At the end it will be much more complete than this http Dropbox Class.

Maybe you want to contribute to this lib (testing)... I´ll give priorized support on the java lib against this one here.
 

RafaelC

Member
Licensed User
Yes DO; I'll be glad to contribuye to test this library. Elthough my requirements with Dropbox are very basic and I myself am just a newby with limited experience en Android and Java. But I'll do what a I can. Thanks
 

Descartex

Well-Known Member
Licensed User
Does anyone make this work on B4i???
Thank you!
 

jpvniekerk

Active Member
Licensed User
I'm making backup files of the data used in an app, and use this library to copy these backup files to and from the user's Dropbox. After quite a bit of struggle I have everything working now: authentication, file upload, file delete, directory listing, file download, etc. I need some help/advice with some items though...

1) I would like to capture when each job is completed, but I am having difficulty with it. I just want to show a toast message when the upload or download is complete. Any tips on how to do this will be appreciated.

2) Every now and then I also see an unexpected error in the log "JobError: Conflict", but it doesn't seem to affect the app at all - everything works even when I get this error. I have no idea what is causing this - I just don't like things giving me errors!

3) When the app exits, I make an automatic backup. the local backup works, but the dropbox upload of the file does not happen, it gives this in the log: "Object context is paused. Ignoring CallSubDelayed: JobDone". All the dropbox instructions are given before the app closes, but the dropbox actions do not execute. Any idea how I can make this work?

Any help will be appreciated!
 

DonManfred

Expert
Licensed User
All the dropbox instructions are given before the app closes
But you did not wait for the result event get raised.... Wait for the result and THEN exit...

1) I would like to capture when each job is completed, but I am having difficulty with it. I just want to show a toast message when the upload or download is complete. Any tips on how to do this will be appreciated.
Upload, Download... they both give a Result-Event after it finishes. Show the Toast in this event

2) Every now and then I also see an unexpected error in the log "JobError: Conflict"
i never saw this problem/error. Don´t know what the problem is.
 

jpvniekerk

Active Member
Licensed User
Thanks Manfred,
Now busy implementing the wait and execute... Must change a lot of the programming logic to accomplish it!

2) Every now and then I also see an unexpected error in the log "JobError: Conflict"
I found the culprit...
The program creates a folder on Dropbox, and this error shows if the folder already exists. I (wrongly) assumed that it will work the same as b4a that it will simply create the folder if it doesn't exist. It does no harm in the program execution, but it throws up an annoying toast message. This may scare the users. I've tried to initialize Dropbox with debug True or False - no difference. Is there any way I can prevent this toast message from showing?
 

jpvniekerk

Active Member
Licensed User
I did the hard yards and first checked if the folder exists on Dropbox, and only create it if it doesn't exist. Error gone now. It's a long way around, but in the end it is the better option.:)
 

joazzz

New Member
Licensed User
Thank you for providing your source.
Some bug fixes are needed.

Bug1:
Sub JobDone(Job As HttpJob)
...
If Job.Success Then
Dim res As String
'res=Job.GetString '<<<---large file download out of memory error
'Bug fixes (large file download OK)
If (Job.JobName <> "filedownload") And (Job.JobName <> "getthumbnail") Then
res=Job.GetString
end if
...

Bug2:
Sub Upload(localpath As String, localFilename As String, dstpath As String, dstfilename As String)
...
job.GetRequest.SetHeader("Dropbox-API-Arg", $"{"path":"${File.Combine(dstpath,dstfilename)}", "mode": "overwrite"}"$)

unicode filename error
java.lang.IllegalArgumentException:
Unexpected char 0xac00 at 10 in Dropbox-API-Arg value: {"path":"/印刷.txt", "mode": "overwrite"}

'Bug Fix
Dim StrUniEsc As String = UnicodeEscape(File.Combine(dstpath,dstfilename))
job.GetRequest.SetHeader("Dropbox-API-Arg", $"{"path":"${StrUniEsc}", "mode": "overwrite"}"$)


Sub Download(path As String, destpath As String, destfile As String)
.....
' job.GetRequest.SetHeader("Dropbox-API-Arg", $"{"path":"${path}"}"$)
'Bug Fix
Dim StrUniEsc As String = UnicodeEscape(path)
job.GetRequest.SetHeader("Dropbox-API-Arg", $"{"path":"${StrUniEsc}"}"$)


HTTP header "Dropbox-API-Arg": could not decode input as JSON
https://www.dropboxforum.com/t5/API...ot-could-not-decode-input-as/m-p/195155#M8876

https://www.b4x.com/android/forum/threads/help-to-convert-from-unicode.32402/
Sub UnicodeEscape (s As String) As String
Dim sb As StringBuilder
sb.Initialize
For i = 0 To s.Length - 1
Dim u As String = Bit.ToHexString(Asc(s.CharAt(i)))
sb.Append("\u")
For i2 = 1 To 4 - u.Length
sb.Append("0")
Next
sb.Append(u)
Next
Return sb.ToString
End Sub

Bug3:
[beta] Dropbox SDK V2 - Java : bug : delete error message


Etc..
dbxAuth : Login Activity Form
'*Prevent : Login Textbox hidden below keyboard
Sub Globals
Private www As WebView
Dim Ime1 As IME
End Sub
Sub Activity_Create(FirstTime As Boolean)
Ime1.Initialize("EvtIme")
Ime1.AddHeightChangedEvent
End Sub
Sub EvtIme_HeightChanged(NewHeight As Int, OldHeight As Int)
www.Height=NewHeight '(www ->WebView1)
End Sub
 
Last edited:
Top