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

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Aug 2, 2015.

  1. rafaelmotaquintana

    rafaelmotaquintana Member Licensed User

    When trying to use the sample code to get the user token, I get this error from dropbox:

    Error (400)
    It seems the app you were using submitted a bad request. If you would like to report this error to the app's developer, include the information below.


    More details for developers
    Invalid redirect_uri. It must exactly match one of the redirect URIs you've pre-configured for your app (including the path

    it happens in this line

    www.LoadUrl("https://www.dropbox.com/1/oauth2/authorize?client_id="& Main.clientID &"&response_type=token&redirect_uri=http://127.0.0.1/")



    WHat Am I missing?
    Thanks
     
  2. DonManfred

    DonManfred Expert Licensed User

    Did you check this error? For the code you posted you need to have configured the url http://127.0.0.1/ when creating the app in the Dropbox developer console

    [​IMG]
     
  3. rafaelmotaquintana

    rafaelmotaquintana Member Licensed User

    That was it.
    It was no so clear, its the first time I deal with something like that.
    Thanks.
     
  4. rafaelmotaquintana

    rafaelmotaquintana Member Licensed User

    Does anybody happens to know how to test if a folder exists?
    Using listfolder, listfolders or search works if the folder exists, but if it doesn't exists, no event is raised so I can not know.
     
  5. DonManfred

    DonManfred Expert Licensed User

    get a list of the parent folder and see if your folder is available in the result
     
  6. rafaelmotaquintana

    rafaelmotaquintana Member Licensed User

  7. rafaelmotaquintana

    rafaelmotaquintana Member Licensed User

    While uploading a file, If the device goes to idle (screen off), after turn it on, activity resume is launched.
    How do I know if there's a dropbox operation currently running, like download or upload?
     
  8. DonManfred

    DonManfred Expert Licensed User

    You need to remember yourself when starting a upload/download. Internal it is using a httpjob to transfer.
    so, if the resulting event is raised then the file is up/downloaded.
     
  9. rafaelmotaquintana

    rafaelmotaquintana Member Licensed User

    Ok I understand. By the way, I made this experiment, while uploading a big file, I disconnected the device from the internet, and I'd like to know if there's an event that raises so I could check if there is a problem. I the meantime, a message 'Uploading file' keeps forever displayed.
     
  10. DonManfred

    DonManfred Expert Licensed User

    i don´t think there is an event.
    the httpjob is running. If it stops the JobDone in the Dropbox-Class is raised. Maybe there is an error in the log?!
     
  11. divinglog

    divinglog Member Licensed User

    Hi

    When I download large files (around 50 MB, sometimes less), my app is closed by Android because of an OutOfMemoryError. Is there a workaround for this problem? Here is the stack trace:

    Code:
    java.lang.OutOfMemoryError: Failed to allocate a 69075310 byte allocation with 16777216 free bytes and 47MB until OOM
        at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:
    95)
        at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:
    115)
        at java.lang.StringBuilder.append(
    StringBuilder.java:249)
        at anywheresoftware.b4a.objects.streams.File$TextReaderWrapper.ReadAll(
    File.java:590)
        at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(
    httpjob.java:189)
        at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(
    httpjob.java:174)
        at b4a.example.dropbox._jobdone(dropbox.java:
    1891)
        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:
    145)
        at android.app.ActivityThread.main(ActivityThread.java:
    6873)
        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:
    1404)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    1199)
     
  12. DonManfred

    DonManfred Expert Licensed User

    does not look like an problem in the lib. sounds more like an problem in your code.
    What do you do with the file which is downloaded?

    What is your code used?
     
  13. divinglog

    divinglog Member Licensed User

    I think the problem is in the httputils2 lib, not directly in the Dropbox lib. It's a SQLite database file, but the app is closed in the middle of the download, so I do nothing with the file yet. Here is the relevant part of the code:

    Code:
    Sub Class_Globals
       
    Private dbx As DropBox
    End Sub

    Public Sub DownloadFile(RemoteFile As String)
        
    Dim Tempstr As String
        
    Dim LocalPath As String
        
    Dim LocalFile As String
       
        Tempstr = DivelogFolder & 
    "/" & RemoteFile
       
        
    If Command = "DownloadMF" Then
            LocalPath = 
    File.DirInternal
            LocalFile = m_MetadataFile
        
    Else
            LocalPath = Common.LogDir
            LocalFile = m_SyncInfo.SqliteFile
        
    End If
       
        
    Try
            dbx.Download(Tempstr, LocalPath, LocalFile)
        
    Catch
            
    If Command = "DownloadMF" Then
                DeleteMetadataFile
                m_AvailableLogbooks.Clear
                m_SyncInfo.Available = 
    False
                
    If SubExists(m_Callback, m_Event & "_SyncInfoChanged"Then
                    
    CallSub(m_Callback, m_Event & "_SyncInfoChanged")
                
    End If
            
    Else
                
    Log(LastException)
                
    ToastMessageShow(Command & " Error: " & LastExceptionTrue)
            
    End If
        
    End Try
       
    End Sub
     
  14. SNOUHyhQs2

    SNOUHyhQs2 Member Licensed User

  15. DonManfred

    DonManfred Expert Licensed User

    This library IS using the V2 Api... The java version does nothing other. But you need to write a wrapper for the java part to make it useable with b4a.
     
  16. SNOUHyhQs2

    SNOUHyhQs2 Member Licensed User

    thanks, tried it and still works. nice job.
     
  17. pappicio

    pappicio Active Member Licensed User

    Hi all, is possible to have an example with download, upload and list? I'm trying to use this lbrary, but without any success.
    thanks.

    EDIT:
    Okok, all listed into class src. thanks a lot.
     
    Last edited: Jul 4, 2016
  18. SNOUHyhQs2

    SNOUHyhQs2 Member Licensed User

    Hi!
    In FileUpload, is there an event that will trigger Upload Fail?

    UploadSessionStatus doesn't seem to trigger upload fail, i tried it without network connection but it does not work.
     
  19. Mikonios

    Mikonios Active Member Licensed User

    Hello DonManfred:

    I have developped a project with B4A-V3.82.
    Communicating through emails and ftp with different servers.
    I want to expand communications via DropBox.
    I see The Sync API has-been deprecated.
    As is impossible DropBox V3.82.

    Supports your new Dropbox API V2 with B4A-V3.82?
    I need to acquire new version of B4a?
     
  20. DonManfred

    DonManfred Expert Licensed User

    I dont know. Try it and you´ll know.
    I suggest to update to b4a 6. Your version is 3 Years old...
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice