Android Question Dropbox SDK V2 - Java: problem downloading

Tom Tran

Member
Licensed User
Hi,
I am using the Dropbox SDK V2 - Java and I can connect, list files, and even upload files. However, when I try to download a file, the file that I end up with is empty (0 bytes). I have tried several different files, all of them are small in size. Any ideas or suggestions?
Here is the download (and upload) code:
B4X:
Sub btnGetFile_Click
    dbxFiles.download("/Work/test.txt", File.DirDefaultExternal, "test.txt")
End Sub

Sub btnSendFile_Click
    dbxFiles.upload(File.DirDefaultExternal, "1.jpg", "/Work/" & "1.jpg", False, False)
End Sub
When the download is performed, in the log I get:
files.download()
files.download(after new File())
files.download(create fos)
files.download(fos created)
 

Tom Tran

Member
Licensed User
Follow the Runtimepermissions tutorial.
So I followed the tutorial and I still have the exact same problem.
B4X:
    Dim testfolder As String = rp.GetSafeDirDefaultExternal("Save")
    File.WriteString(testfolder,"test.txt","aaa")
    dbxFiles.download("/work/temp.htm", testfolder, "Temp.htm")
The code above creates two files. File test.txt contains aaa and file Temp.htm is empty. On Dropbox, file Temp.htm is not empty.
Any other advice?
 

drgottjr

Well-Known Member
Licensed User
dropbox is case-insensitive, android is not. you're asking for trouble by the way you switch back and forth when naming files and folders and referencing them.
the log messages are generated by you; they'll say anything you tell them to say.
 

Tom Tran

Member
Licensed User
dropbox is case-insensitive, android is not. you're asking for trouble by the way you switch back and forth when naming files and folders and referencing them.
the log messages are generated by you; they'll say anything you tell them to say.
Thank you for the input, but I have already tried several variations of capitalization since in different places within Dropbox, I can see things both all lower case and capitalizing the first letter of the directory and file and I get the exact same results every time.
 

Tom Tran

Member
Licensed User
Try using try catch for the download. It may reveal more info
B4X:
    Try
        dbxFiles.download("/Work/Temp.htm", testfolder, "Temp.htm")
    Catch
        Log(LastException)
    End Try
Nothing was added to the log, so I suppose that no exception occurred.
 

DonManfred

Expert
Licensed User
Try this version and the new jar from Dropbox


As meta can be null you need to check....
B4X:
Sub dbxFiles_DownloadFinished(success As Boolean, meta As FileMetadata, error As String)
    If meta = Null Then
        Log($"dbxFiles_DownloadFinished(${success}, ${error})"$)
    Else
        Log($"dbxFiles_DownloadFinished(${success}, ${meta}, ${error})"$)
    End If
    If error.Contains("Exception") Then
        Log(LastException)
    End If

End Sub
 

Attachments

Tom Tran

Member
Licensed User
Try this version and the new jar from Dropbox


As meta can be null you need to check....
B4X:
Sub dbxFiles_DownloadFinished(success As Boolean, meta As FileMetadata, error As String)
    If meta = Null Then
        Log($"dbxFiles_DownloadFinished(${success}, ${error})"$)
    Else
        Log($"dbxFiles_DownloadFinished(${success}, ${meta}, ${error})"$)
    End If
    If error.Contains("Exception") Then
        Log(LastException)
    End If

End Sub
Yes! That did it! Thank you very much!
 

Sabotto

Active Member
Licensed User
I have the same problem. I downloaded version 3.1.4 of the library. But now in the library folder I have both 3.0.10 and 3.1.4. If I remove the 3.0.10, during compilation it asks me.
Do I have to keep them both?

And how can I test if the file "Temp1.htm" exists?

B4X:
dbxFiles.download("/MyFolder/Temp1.htm", testfolder, "Temp2.htm")
Because I believe it is not detected..
 

DonManfred

Expert
Licensed User
Do I have to keep them both?
with the newest library version you only need the newest jar.
Only one of them is needed.
Because I believe it is not detected..
you need to get a filelist from the folder first to check which files are inside this folder.

I do not answer any more questions in this thread.
 
Top