B4A Library Dropbox SDK V2 - Java

dropbox_blue.png



This is a wrap for the Dropbox JAVA SDK for Android.

It is a request for the community too to parcitipate to this project doing test or writing documentation for the objects.

List of connected Tutorials:
- Dropbox SDK V2 - Authentification
- Dropbox SDK V2 - Uploading big files to Dropbox
- Dropbox SDK - get informed about changes in the used Dropbox


DropboxV2
Comment:
The Dropbox library allows you to communicate with Dropbox
Author: DonManfred (wrapper)
Version: 0.65 (wraps the SDK dropbox-core-sdk-6.0.0)

Wrapped Objects so far
  • DbxAuth
  • DbxClientV2
  • DbxHost
  • Dimensions
  • DbxRequestConfig
  • DbxUserAuthRequests
  • DropboxV2
  • DbxUserFilesRequests
  • FileMetadata
  • FolderMetadata
  • FolderSharingInfo
  • GpsCoordinates
  • Mediainfo
  • MediaMetadata
  • Metadata
  • RelocationPath
  • DbxUserSharingRequests
  • MemberSelector
  • SharedFileMetadata
  • SharedFolderMetadata
  • SharedLinkMetadata
  • BasicAccount
  • FullAccount
  • DbxUserUsersRequests

The Download will always be here in Post #1 of the Thread.

Additional to the provided Library (xml and jar) you need to download:
1. Download this file.
Extract the zip and copy the files to your additional libraries folder.

Add this lines to your Mainmodule
B4X:
#AdditionalJar:dropbox-android-sdk-6.0.0.aar
#AdditionalJar:dropbox-core-sdk-6.0.0


In the following posts i´ll add some more detailed info on the different Objects.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Part 1 - Authentification

Connected Tutorial: Dropbox SDK V2 - Authentification

  • DbxUserAuthRequests
    Methods:
  • tokenRevoke As void
  • toString As java.lang.String
  • IsInitialized As boolean
    You will need this Object to revoke a given token. Usually you dont need it. The Authentification is done through the DbxAuth object (see the following description).... The DbxUserAuthRequests object is given by calling "auth" from the DropboxClient-Object

Usually you dont have a token if you want to connect to a users dropbox.

In this case we need to follow the OAuth-Flow to get an AccessToken.

to prepare yor app to use the Auth-Activity from dropbox you need to add this snippet to your Manifest-Editor

AddManifestText(
<queries>
<package android:name="com.dropbox.android" />
</queries>
)
AddApplicationText(
<activity
android:name="com.dropbox.core.android.AuthActivity"
android:exported="true"
android:configChanges="orientation|keyboard"
android:launchMode="singleTask">
<intent-filter>
<data android:scheme="db-xxx" />

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- Additional intent-filter required as a workaround for Apps using targetSdk=33 until the fix in the Dropbox app is available to all users. https://github.com/dropbox/dropbox-sdk-java/issues/406 -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
)

Please note that you need to change the scheme line
change db-xxx in db-yourappkey

To start the flow you need to have a
B4X:
    Dim auth As DbxAuth
   Dim config As DbxRequestConfig
   Dim dbxFiles As DbxUserFilesRequests
   Dim dbxSharing As DbxUserSharingRequests
   Dim dbxUsers As DbxUserUsersRequests
followed (in activity create) by a
B4X:
auth.Initialize("xxx")
where xxx is your appid from dropbox.

Start the Authentification from within a button click for example

B4X:
auth.startOAuth2Authentication

Check the OAuthtoken in activity resume

B4X:
Sub Activity_Resume
    If auth.OAuth2Token <> Null Then
        If auth.OAuth2Token <> "" Then
            token = auth.OAuth2Token ' token is a global string i used here
            lblToken.Text = token ' this is the label define in my testproject holding the token
            DropboxEnabled = True ' to know Dropbox can be used now
            btnListroot.Enabled = True ' in my example the button to do something is only clickable after Authentification.
            Starter.kvs.Put("token", token) ' Store token to a kvs
            Log("Token available. Dropbox enabled")
            config.Initialize("",token,"","de-de",5) '
            Dim dbxhost As DbxHost
            dbxhost.Initialize
            client.Initialize("Dropbox",config,token,dbxhost)

After this we can use Dropbox.

Please note that the lib contains several objects to do something.

All request-objects you get from the initialized client. NOTE that the request-objects have not yet set a Eventname...

You need to set the Eventname (and a correct ref to b4a) with

B4X:
        dbxFiles = client.files
        dbxFiles.setEventname("dbxFiles")
        dbxSharing = client.sharing
        dbxSharing.setEventname("dbxSharing")
        dbxUsers = client.users
        dbxUsers.setEventname("dbxUsers")

NOW you are ready to go

Following the code for the Auth-Example

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region


Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim auth As DbxAuth
    Dim Dropbox As DropboxV2
    Dim token As String
    Dim DropboxEnabled As Boolean
    Dim client As DbxClientV2
    Dim config As DbxRequestConfig
    Dim dbxFiles As DbxUserFilesRequests
    Dim dbxSharing As DbxUserSharingRequests
    Dim dbxUsers As DbxUserUsersRequests
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
 
    Private btnStartOAuth As Button
    Private lblToken As Label
    Private btnListroot As Button
    Private downloadrunning As Boolean
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("OAuth")
    Dim dummy As String
    dummy = Starter.kvs.GetDefault("token", "")
    If dummy <> "" Then
        token = dummy
        lblToken.Text = token
        Log("Token available (Activity Create. Try to enable Dropbox with this token")
        config.Initialize("",token,"","de-de",5)
        Dim dbxhost As DbxHost
        dbxhost.Initialize
        client.Initialize("Dropbox",config,token,dbxhost)
        dbxFiles = client.files
        dbxFiles.setEventname("dbxFiles")
        dbxSharing = client.sharing
        dbxSharing.setEventname("dbxSharing")
        dbxUsers = client.users
        dbxUsers.setEventname("dbxUsers")
    End If
    btnListroot.Enabled = False
    DropboxEnabled = False
    Dropbox.Initialize("")
    auth.Initialize("8bgblt25ldqwh70")
    downloadrunning = False
End Sub

Sub Activity_Resume
    If auth.OAuth2Token <> Null Then
        If auth.OAuth2Token <> "" Then
            token = auth.OAuth2Token
            lblToken.Text = token
            DropboxEnabled = True
            btnListroot.Enabled = True
            Starter.kvs.Put("token", token)
            Log("Token available. Dropbox enabled")
            config.Initialize("",token,"","de-de",5)
            Dim dbxhost As DbxHost
            dbxhost.Initialize
            client.Initialize("Dropbox",config,token,dbxhost)
            dbxFiles = client.files
            dbxFiles.setEventname("dbxFiles")
            dbxSharing = client.sharing
            dbxSharing.setEventname("dbxSharing")
            dbxUsers = client.users
            dbxUsers.setEventname("dbxUsers")
       
        Else
            Log($"Token = """$)
        End If
    Else
        Log("Token is NULL")
        If token <> "" Then
            Log("Try to use the known token...")
            'dbxFiles.listFolder("/B4A/",False,True,False,True,false)
            'dbxSharing.listFolders  ' Tested!
            dbxUsers.CurrentAccount ' Tested!
        End If
    End If
 
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnStartOAuth_Click
    auth.startOAuth2Authentication
End Sub

Sub btnListroot_Click
    dbxFiles.listFolder("",False,True,False,True,True)
    'dbxSharing.listFolders  ' Tested!
    'dbxUsers.CurrentAccount ' Tested!
End Sub






Sub dbxSharing_listFolders(success As Boolean, folders As List, error As String)
    Log($"dbxSharing_listFolders(${success}, ${folders.Size}, ${error})"$)
    If folders.Size > 0 Then
        For i = 0 To folders.Size-1
            Dim meta As SharedFolderMetadata = folders.Get(i)
            'Log(meta.toString)
        Next
    End If
End Sub
Sub dbxSharing_AddFileMember(success As Boolean, members As List, error As String)
    Log($"dbxSharing_listFolders(${success}, ${members.Size}, ${error})"$)
End Sub
Sub dbxSharing_listMountableFolders(success As Boolean, folders As List, error As String)
    Log($"dbxSharing_listFolders(${success}, ${folders.Size}, ${error})"$)
End Sub
Sub dbxSharing_listReceivedFiles(success As Boolean, receivedFiles As List, error As String)
    Log($"dbxSharing_listFolders(${success}, ${receivedFiles.Size}, ${error})"$)
 
End Sub
Sub dbxSharing_listSharedLinks(success As Boolean, sharedLinks As List, error As String)
    Log($"dbxSharing_listFolders(${success}, ${sharedLinks.Size}, ${error})"$)
End Sub
Sub dbxSharing_SharedFolderMetadata(success As Boolean, meta As SharedFolderMetadata, error As String)
    Log($"dbxSharing_listFolders(${success}, ${meta.toString}, ${error})"$)

End Sub









Sub dbxFiles_DownloadFinished(success As Boolean, meta As FileMetadata, error As String)
    Log($"dbxFiles_DownloadFinished(${success}, ${meta}, ${error})"$)
End Sub
Sub dbxFiles_listFolder(success As Boolean, content As List, error As String)
    Log($"dbxFiles_listFolders(${success}, ${content.Size}, ${error})"$)
    If content.Size > 0 Then
        For i = 0 To content.Size-1
            Dim meta As Metadata = content.Get(i)
            'Log(meta.toString)
        Next
    End If
 
End Sub
Sub dbxFiles_CopyBatch(success As Boolean, meta As Map, error As String)
 
End Sub
Sub dbxFiles_CopyBatchCheck(success As Boolean, meta As Map, error As String)
 
End Sub
Sub dbxFiles_CopyReference(metainfo As Map)
 
End Sub
Sub dbxFiles_CreateFolder(success As Boolean, meta As FolderMetadata, error As String)
 
End Sub
Sub dbxFiles_ListRevisions(success As Boolean, meta As Map, error As String)
 
End Sub
Sub dbxFiles_MoveBatch(success As Boolean, meta As Map, error As String)
 
End Sub
Sub dbxFiles_MoveBatchCheck(success As Boolean, meta As Map, error As String)
 
End Sub
Sub dbxFiles_Restore(success As Boolean, meta As FileMetadata, error As String)
 
End Sub
Sub dbxFiles_UploadFinished(success As Boolean, meta As FileMetadata, error As String)
 
End Sub

Sub dbxUsers_getAccount(account As BasicAccount)
    Log($"dbxUsers_getAccount(${account})"$)
End Sub
Sub dbxUsers_getAccountBatch(batch As List)
 
End Sub
Sub dbxUsers_getCurrentAccount(account As FullAccount)
    Log($"dbxUsers_getCurrentAccount(${account})"$)
 
End Sub
 

Attachments

  • DropboxV2Example1-Auth.zip
    10.7 KB · Views: 729
Last edited:

DonManfred

Expert
Licensed User
Longtime User
The following appends to ALL Requests (UserRequests, Files-Requests and Sharing-Requests)!

Note that all calls to one of the methods will be handled in a new Thread and after it finishes a event is raised.

For example: a call to CurrentAccount will raise the event CurrentAccount(account As FullAccount). A similar Event will be raised by all other methods too.

Part 2 - UserRequests (finished)
  • DbxUserUsersRequests
    Events:
  • getAccount (account As BasicAccount)
  • getCurrentAccount (account As FullAccount)
  • getAccountBatch (batch As List)
  • getSpaceUsage (usage As SpaceUsage)
    Methods:
  • Account (accountId As java.lang.String) As void
  • CurrentAccount As void
  • AccountBatch (accountIds As java.util.List) As void
  • IsInitialized As boolean
  • setEventname (ba As anywheresoftware.b4a.BA, EventName As java.lang.String) As void
    Properties:
  • SpaceUsage As void [read only]
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Part 3 - Files-Requests (unfinished)

Note that all methods without a description are just wrapped. The documentation for these methods needs to be written and the methods needs to be tested.

DbxUserFilesRequests
Events:

  • CreateFolder (success As boolean, meta As FolderMetadata, error As String)
  • Copy (success As boolean, meta As Metadata, error As String)
  • CopyBatch (success As boolean, meta As Map, error As String)
  • CopyBatchCheck (success As boolean, meta As Map, error As String)
  • CopyReference (metainfo As Map)
  • DownloadFinished (success As boolean, meta As FileMetadata, error As String)
  • LatestCursor (success As boolean, path As String, cursor As String, error As String)
  • ListFolder (success As boolean, content As List, error As String)
  • ListFolderLatestCursor (success As boolean, content As List, error As String)
  • ListRevisions (success As boolean, meta As Map, error As String)
  • LongPoll (success As boolean, changes As boolean, BackOff As long, error As String)
  • Move (success As boolean, meta As Metadata, error As String)
  • MoveBatch (success As boolean, meta As Map, error As String)
  • MoveBatchCheck (success As boolean, meta As Map, error As String)
  • Preview (success As boolean, meta As FileMetadata, error As String)
  • Restore (success As boolean, meta As FileMetadata, error As String)
  • SaveURL (success As boolean, meta As Map, info As String)
  • SaveURLJobStatus (success As boolean, meta As Map, info As String)
  • TemporaryLink (success As boolean, path As String, link As String, meta As FileMetadata)
  • UploadFinished (success As boolean, meta As FileMetadata, error As String)
  • UploadSessionFinished (session As Map)
  • UploadSessionProgress (session As Map)
  • PermanentlyDelete (sucess As boolean, path As String, error As Strin)
Methods:
  • listRevisions (path As java.lang.String) As void
    Return revisions of a file.
  • dummy2 As void
  • getPreview (path As java.lang.String, localPath As java.lang.String, localFilename As java.lang.String) As void
    Get a preview for a file. Currently previews are only generated for
    the files with the following extensions: .doc, .docx, .docm, .ppt,
    .pps, .ppsx, .ppsm, .pptx, .pptm, .xls, .xlsx, .xlsm, .rtf.
  • getcopyReference (path As java.lang.String) As void
    Get a copy reference to a file or folder. This reference
    string can be used to save that file or folder to
    another user's Dropbox by passing it to copy_reference/save.
  • createFolder2 (path As java.lang.String, autorename As boolean) As void
    Create a folder at a given path.
    If autorename is set to true then the new folder will become
    renamed automatically.
  • upload (localPath As java.lang.String, localFilename As java.lang.String, destination As java.lang.String, AutoRename As boolean, mute As boolean) As void
    Create a new file with the contents provided in the request.
    Do not use this to upload a file larger than 150 MB.
    Instead, create an upload session with upload_session/start.
  • setDebugLog (ba As anywheresoftware.b4a.BA, enabled As boolean) As void
  • IsInitialized As boolean
  • getThumbnail (path As java.lang.String, format As com.dropbox.core.v2.files.ThumbnailFormat, size As com.dropbox.core.v2.files.ThumbnailSize, localPath As java.lang.String, localFilename As java.lang.String) As void
    Get a thumbnail for an image.
    This method currently supports files with the following
    file extensions: jpg, jpeg, png, tiff, tif, gif and bmp.

    Photos that are larger than 20MB in size won't be
    converted to a thumbnail.
  • getPreview2 (path As java.lang.String, rev As java.lang.String, localPath As java.lang.String, localFilename As java.lang.String) As void
    Get a preview for a file. Currently previews are only generated for
    the files with the following extensions: .doc, .docx, .docm, .ppt,
    .pps, .ppsx, .ppsm, .pptx, .pptm, .xls, .xlsx, .xlsm, .rtf.
  • listRevisions2 (path As java.lang.String, limit As long) As void
    Return revisions of a file.
  • delete (path As java.lang.String) As void
    Delete the file or folder at a given path. If the path is a
    folder, all its contents will be deleted too.
    A successful response indicates that the file or folder was
    deleted. The returned metadata will be the corresponding
    FileMetadata or FolderMetadata for the item at time of
    deletion, and not a DeletedMetadata object.
  • deleteBatch (entries As java.util.List) As void
    Delete multiple files/folders at once.
    This route is asynchronous, which returns a
    job ID immediately and runs the delete batch
    asynchronously. Use delete_batch/check to
    check the job status.
  • setEventname (ba As anywheresoftware.b4a.BA, EventName As java.lang.String) As void
  • saveUrl (path As java.lang.String, url As java.lang.String) As void
    Save a specified URL into a file in user's Dropbox.
    If the given path already exists, the file will be
    renamed to avoid the conflict (e.g. myfile (1).txt).
  • search (path As java.lang.String, query As java.lang.String, mode As java.lang.String, maxResults As long, startAt As long) As void
    Searches for files and folders.
    Note: Recent changes may not immediately be
    reflected in search results due to a short
    delay in indexing.
  • download (path As java.lang.String, localPath As java.lang.String, localFilename As java.lang.String) As void
    Downloads the file "path" and store it in the
    path "localPath" under the filename "localFilename".
    DEV:Tested
  • download2 (path As java.lang.String, rev As java.lang.String, localPath As java.lang.String, localFilename As java.lang.String) As void
    Downloads the file "path" with the revision "rev" and store it
    in the path "localPath" under the filename "localFilename".
    DEV:NOT Tested
  • MoveBatchCheck (asyncJobId As java.lang.String) As void
    Returns the status of an asynchronous job for move_batch.
  • copyBatch (entries As java.util.List) As void
    Copy multiple files or folders to different locations at once in the
    user's Dropbox. If RelocationBatchArg.allow_shared_folder is false,
    this route is atomic. If on entry failes, the whole transaction will
    abort. If RelocationBatchArg.allow_shared_folder is true, not
    atomicity is guaranteed, but you will be able to copy the contents
    of shared folders to new locations.
    This route will return job ID immediately and do the async copy job
    in background. Please use copy_batch/check to check the job status.
  • listFolderLatestCursor (pba As anywheresoftware.b4a.BA, path As java.lang.String, includeDeleted As boolean, includeHasExplicitSharedMembers As boolean, includeMediaInfo As boolean, recursive As boolean, debuglog As boolean) As void
    A way to quickly get a cursor for the folder's state. Unlike
    list_folder, list_folder/get_latest_cursor doesn't return any
    entries. This endpoint is for app which only needs to know
    about new files and modifications and doesn't need to know
    about files that already exist in Dropbox.
  • listFolderLongpoll (cursor As java.lang.String) As void
    A longpoll endpoint to wait for changes on an account. In conjunction
    with list_folder/continue, this call gives you a low-latency way to
    monitor an account for file changes. The connection will block until
    there are changes available or a timeout occurs.
  • createFolder (path As java.lang.String) As void
    Create a folder at a given path.
  • copy (fromPath As java.lang.String, toPath As java.lang.String) As void
    Copy a file or folder to a different location
    in the user's Dropbox. If the source path is
    a folder all its contents will be copied.
    fromPath:
    toPath: DEV:not tested!
  • permanentlyDelete (path As java.lang.String) As void
    Permanently delete the file or folder at a given
    path (see https://www.dropbox.com/en/help/40).
    Note: This endpoint is only available for Dropbox Business apps.
  • move (fromPath As java.lang.String, toPath As java.lang.String) As void
    Move a file or folder to a different
    location in the user's Dropbox.
    If the source path is a folder
    all its contents will be moved.
  • getMetadata (path As java.lang.String, includeDeleted As boolean, includeHasExplicitSharedMembers As boolean, includeMediaInfo As boolean, debuglog As boolean) As void
    Returns the metadata for a file or folder.
    Note: Metadata for the root folder is unsupported.
    path: DEV:not tested!
  • restore (path As java.lang.String, rev As java.lang.String) As void
    Restore a file to a specific revision.
  • getDownloadbuilder (path As java.lang.String) As com.dropbox.core.v2.files.DownloadBuilder
  • listFolder (pba As anywheresoftware.b4a.BA, path As java.lang.String, includeDeleted As boolean, includeHasExplicitSharedMembers As boolean, includeMediaInfo As boolean, recursive As boolean, debuglog As boolean) As void
    Lists the content from path "path"
    - If "includeDeleted" is set to true then deleted
    files/folders are listed too. See Metadata for
    details on each entry.

    - is "includeHasExplicitSharedMembers" is set to
    true then "i dont know what happens ;) See
    Dropbox site for more info ;-)

    - if "includeMediaInfo" is set to true then the
    result will ontain MediaInfo too (pictures and video)

    - If "recursive" is set to true then the Folder will
    be listed recursively. Note that this could result in
    a long list of Metadatas.

    - If "debuglog" is set to true then the lib will do
    some LOG-Output so see where it hangs

    DEV:Tested!
  • moveBatch (relocation As java.util.List, allowSharedFolder As boolean, autorename As boolean) As void
    Move multiple files or folders to different locations
    at once in the user's Dropbox.
    This route is 'all or nothing', which means if one entry
    fails, the whole transaction will abort.

    This route will return job ID immediately and do
    the async moving job in background. Please use
    move_batch/check to check the job status.
  • copyBatchCheck (batchID As java.lang.String) As void
    Returns the status of an asynchronous job for
    copy_batch. If success, it returns list of
    results for each entry.
  • listFolderLongpoll2 (cursor As java.lang.String, timeout As long) As void
    A longpoll endpoint to wait for changes on an account. In conjunction
    with list_folder/continue, this call gives you a low-latency way to
    monitor an account for file changes. The connection will block until
    there are changes available or a timeout occurs.
  • getTemporaryLink (pba As anywheresoftware.b4a.BA, path As java.lang.String) As void
    Get a temporary link to stream content of a file.
    This link will expire in four hours and afterwards
    you will get 410 Gone.
    Content-Type of the link is determined
    automatically by the file's mime type.
  • saveUrlCheckJobStatus (asyncJobId As java.lang.String) As void
    Check the status of a save_url job.
  • deleteBatchCheck (batchID As java.lang.String) As void
    Returns the status of an asynchronous job for
    delete_batch. If success, it returns list
    of result for each entry.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Part 4 - Sharing-Requests (finished)

Missing Methods:

Note that all methods without a description are just wrapped. The documentation for these methods needs to be written and the methods needs to be tested.

DbxUserSharingRequests
Events:

  • SharedFolderMetadata (success As boolean, meta As SharedFolderMetadata, error As String)
  • SharedFolder (success As boolean, info As Map, info As String)
  • AddFileMember (success As boolean, members As List, error As String)
  • listSharedLinks (success As boolean, sharedLinks As List, error As String)
  • listReceivedFiles (success As boolean, receivedFiles As List, error As String)
  • listFolders (success As boolean, folders As List, error As String)
  • listMountableFolders (success As boolean, folders As List, error As String)
  • UnshareFolder (success As boolean, info As Map, info As String)
  • removeFileMember (success As boolean, info As Map, info As String)
  • UpdateFolderMember (success As boolean, info As Map, info As String)
  • UnshareFile (success As boolean, error As String)
  • umountFolder (success As boolean, sharedFolderId As String, error As String)
  • revokeSharedLink (success As boolean, url As String, error As String)
  • transferFolder (success As boolean, sharedFolderId As String, toDropboxId As String, error As String)
  • relinquishFolderMembership (success As boolean, info As Map, info As String)
  • relinquishFileMembership (success As boolean, fle As String, info As String)
  • mountFolder (success As boolean, meta As SharedFolderMetadata, error As String)
  • modifySharedLinkSettings (success As boolean, meta As SharedLinkMetadata, error As String)
  • listFolderMembers (success As boolean, info As Map, info As String)
  • listFileMembers (success As boolean, info As Map, info As String)
  • listFileMembersBatch (success As boolean, members As List, info As String)
  • SharedLinks (success As boolean, path As String, links As List, error As String)
  • SharedLinkMetadata (success As boolean, url As String, meta As SharedLinkMetadata)
  • DownloadFinished (success As boolean, meta As SharedFileMetadata, error As String)
  • FolderMetadata (sharedFolderId As String, meta As SharedFolderMetadata)
  • FileMetadata (success As boolean, sharedFile As String, meta As SharedFileMetadata, error As String)
  • listFileMetadataBatch (success As boolean, files As List, info As String)
  • createSharedLink (success As boolean, path As String, meta As PathLinkMetadata, error As String)
  • ShareJobStatus (CheckSuccess As boolean, asyncJobId As String, metainfo As Map, error As String)
  • JobStatus (CheckSuccess As boolean, asyncJobId As String, metainfo As Map, error As String)
  • RemoveMemberJobStatus (CheckSuccess As boolean, asyncJobId As String, metainfo As Map, error As String)
  • ChangeFileMemberAccess (success As boolean, path As String, metainfo As Map, error As String)
  • AddFolderMember (success As boolean, sharedFolderId As String, error As String)
Methods:
  • relinquishFileMembership (fle As java.lang.String) As void
    The current user relinquishes their membership in
    the designated file. Note that the current user
    may still have inherited access to this file
    through the parent folder.
    Apps must have full Dropbox access to use this endpoint.
  • addFolderMember (sharedFolderId As java.lang.String, members As java.util.List) As void
    Allows an owner or editor (if the ACL update policy allows)
    of a shared folder to add another member. For the new member
    to get access to all the functionality for this folder, you
    will need to call mount_folder on their behalf.
    Apps must have full Dropbox access to use this endpoint.
  • IsInitialized As boolean
  • getSharedLinkMetadata (url As java.lang.String) As void
    Get the shared link's metadata.
  • dummy As void
  • createSharedLinkWithSettings (path As java.lang.String, settings As com.dropbox.core.v2.sharing.SharedLinkSettings) As void
    Create a shared link with custom settings. If no settings are given
    then the default visibility is RequestedVisibility.public (The
    resolved visibility, though, may depend on other aspects such as
    team and shared folder settings).
  • listFileMembers2 (fle As java.lang.String, includeInherited As boolean, limit As long) As void
    Use to obtain the members who have been invited
    to a file, both inherited and uninherited members.
  • checkRemoveMemberJobStatus (asyncJobId As java.lang.String) As void
    Returns the status of an asynchronous job
    for sharing a folder.

    Apps must have full Dropbox access to use
    this endpoint.
  • listFileMembers3 (fle As java.lang.String, includeInherited As boolean, limit As long, actions As java.util.List) As void
    Use to obtain the members who have been invited
    to a file, both inherited and uninherited members.
  • checkJobStatus (asyncJobId As java.lang.String) As void
    Returns the status of an asynchronous job.
    Apps must have full Dropbox access to use this endpoint.
  • unmountFolder (sharedFolderId As java.lang.String) As void
    The current user unmounts the designated folder. They can
    re-mount the folder at a later time using mount_folder.
    Apps must have full Dropbox access to use this endpoint.
  • listFileMembersBatch (files As java.util.List) As void
    Get members of multiple files at once. The arguments to
    this route are more limited, and the limit on query
    result size per file is more strict. To customize the
    results more, use the individual file endpoint.

    Inherited users and groups are not included in the
    result, and permissions are not returned for this endpoint.
  • listFolders As void
    Return the list of all shared folders the current
    user has access to.
    Apps must have full Dropbox access to use this endpoint.
  • modifySharedLinkSettings (url As java.lang.String, settings As com.dropbox.core.v2.sharing.SharedLinkSettings) As void
    Modify the shared link's settings. If the requested
    visibility conflict with the shared links policy of
    the team or the shared folder (in case the linked file
    is part of a shared folder) then the
    LinkPermissions.resolved_visibility of the returned
    SharedLinkMetadata will reflect the actual visibility
    of the shared link and the
    LinkPermissions.requested_visibility will reflect
    the requested visibility.
  • GetFileMetadata2 (sharedFile As java.lang.String, actions As java.util.List) As void
    Returns shared file metadata.
  • mountFolder (sharedFolderId As java.lang.String) As void
    The current user mounts the designated folder.
    Mount a shared folder for a user after they have
    been added as a member. Once mounted, the shared
    folder will appear in their Dropbox.
    Apps must have full Dropbox access to use this endpoint.
  • addFileMember (file As java.lang.String, members As java.util.List) As void
    Adds specified members to a file.
  • getFolderMetadata (sharedFolderId As java.lang.String) As void
    Returns shared folder metadata by its folder ID.
    Apps must have full Dropbox access to use this endpoint.
  • listSharedLinks (path As java.lang.String) As void
    List shared links of this user. If no path is
    given, returns a list of all shared links for
    the current user.
    If a non-empty path is given, returns a list
    of all shared links that allow access to the
    given path - direct links to the given path
    and links to parent folders of the given path.
    Links to parent folders can be suppressed
    by setting direct_only to true.
  • unshareFolder2 (sharedFolderId As java.lang.String, leaveacopy As boolean) As void
    Allows a shared folder owner to unshare the folder.
    You'll need to call check_job_status to determine
    if the action has completed successfully.
    Apps must have full Dropbox access to use this endpoint.
  • listFileMetadataBatch (files As java.util.List) As void
    Returns shared file metadata.
  • changeFileMemberAccess (file As java.lang.String, member As com.dropbox.core.v2.sharing.MemberSelector, accessLevel As com.dropbox.core.v2.sharing.AccessLevel) As void
    DEPRECATED BY /update_file_member
  • getSharedLinkFile (url As java.lang.String, linkPassword As java.lang.String, path As java.lang.String, localPath As java.lang.String, localFilename As java.lang.String) As void
    Download the shared link's file from a user's Dropbox.
  • unshareFile (file As java.lang.String) As void
    Remove all members from this file.
    Does not remove inherited members.
  • updateFolderPolicy (sharedFolderId As java.lang.String, aclPolicy As com.dropbox.core.v2.sharing.AclUpdatePolicy, memberPolicy As com.dropbox.core.v2.sharing.MemberPolicy, sharedLinkPolicy As com.dropbox.core.v2.sharing.SharedLinkPolicy) As void
    Update the sharing policies for a shared folder.
    User must have AccessLevel.owner access to the
    shared folder to update its policies.
    Apps must have full Dropbox access to use this endpoint.
  • createSharedLink2 (path As java.lang.String) As void
    DEPRECATED BY /create_shared_link_with_settings
    Create a shared link. If a shared link already exists for
    the given path, that link is returned. Note that in the
    returned PathLinkMetadata, the PathLinkMetadata.url field
    is the shortened URL if CreateSharedLinkArg.short_url
    argument is set to true.
  • getFileMetadata (sharedFile As java.lang.String) As void
    Returns shared file metadata.
  • setDebugLog (ba As anywheresoftware.b4a.BA, enabled As boolean) As void
  • setEventname (ba As anywheresoftware.b4a.BA, EventName As java.lang.String) As void
  • removeFolderMember (sharedFolderId As java.lang.String, member As com.dropbox.core.v2.sharing.MemberSelector, leaveACopy As boolean) As void
    Allows an owner or editor (if the ACL update policy
    allows) of a shared folder to remove another member.
    Apps must have full Dropbox access to use this endpoint.
  • updateFolderMember (sharedFolderId As java.lang.String, member As com.dropbox.core.v2.sharing.MemberSelector, accessLevel As com.dropbox.core.v2.sharing.AccessLevel) As void
    Allows an owner or editor of a shared folder to update
    another member's permissions.
    Apps must have full Dropbox access to use this endpoint.
  • checkShareJobStatus (asyncJobId As java.lang.String) As void
    Returns the status of an asynchronous
    job for sharing a folder.
    Apps must have full Dropbox access
    to use this endpoint.
  • listFileMembersBatch2 (files As java.util.List, limit As long) As void
    Get members of multiple files at once. The arguments to
    this route are more limited, and the limit on query
    result size per file is more strict. To customize the
    results more, use the individual file endpoint.

    Inherited users and groups are not included in the
    result, and permissions are not returned for this endpoint.
  • addFolderMember2 (sharedFolderId As java.lang.String, members As java.util.List, customMessage As java.lang.String, quiet As boolean) As void
    Allows an owner or editor (if the ACL update policy allows)
    of a shared folder to add another member. For the new member
    to get access to all the functionality for this folder, you
    will need to call mount_folder on their behalf.
    Apps must have full Dropbox access to use this endpoint.
  • getFolderMetadata2 (sharedFolderId As java.lang.String, actions As java.util.List) As void
    Returns shared folder metadata by its folder ID.
    Apps must have full Dropbox access to use this endpoint.
  • removeFileMember (file As java.lang.String, member As com.dropbox.core.v2.sharing.MemberSelector) As void
    DEPRECATED BY /remove_file_member_2
    Identical to remove_file_member_2 but with less information returned.
  • revokeSharedLink (url As java.lang.String) As void
    Revoke a shared link.
    Note that even after revoking a shared link to a file, the
    file may be accessible if there are shared links leading
    to any of the file parent folders. To list all shared links
    that enable access to a specific file, you can use the
    list_shared_links with the file as the
    ListSharedLinksArg.path argument.
  • listMountableFolders As void
    Return the list of all shared folders the
    current user can mount or unmount.
    Apps must have full Dropbox access to use this endpoint.
  • getSharedLinkMetadata2 (url As java.lang.String, linkPassword As java.lang.String, path As java.lang.String) As void
    Get the shared link's metadata.
  • unshareFolder (sharedFolderId As java.lang.String) As void
    Allows a shared folder owner to unshare the folder.
    You'll need to call check_job_status to determine
    if the action has completed successfully.
    Apps must have full Dropbox access to use this endpoint.
  • createSharedLink (path As java.lang.String, mode As com.dropbox.core.v2.sharing.PendingUploadMode, shortUrl As boolean) As void
    DEPRECATED BY /create_shared_link_with_settings
    Create a shared link. If a shared link already exists for
    the given path, that link is returned. Note that in the
    returned PathLinkMetadata, the PathLinkMetadata.url field
    is the shortened URL if CreateSharedLinkArg.short_url
    argument is set to true.
  • relinquishFolderMembership2 (sharedFolderId As java.lang.String, leaveACopy As boolean) As void
    The current user relinquishes their membership in
    the designated file. Note that the current user
    may still have inherited access to this file
    through the parent folder.
    Apps must have full Dropbox access to use this endpoint.
  • listFolderMembers (sharedFolderId As java.lang.String) As void
    Returns shared folder membership by its folder ID.
    Apps must have full Dropbox access to use this endpoint.
  • removeFileMember2 (file As java.lang.String, member As com.dropbox.core.v2.sharing.MemberSelector) As void
    Removes a specified member from the file.
  • shareFolder (path As java.lang.String, aclUpdatePolicy As com.dropbox.core.v2.sharing.AclUpdatePolicy, memberPolicy As com.dropbox.core.v2.sharing.MemberPolicy, sharedLinkPolicy As com.dropbox.core.v2.sharing.SharedLinkPolicy, forceAsync As boolean) As void
    Share a folder with collaborators. Most sharing will
    be completed synchronously. Large folders will be
    completed asynchronously. To make testing the async
    case repeatable, set `ShareFolderArg.force_async`.
    If a ShareFolderLaunch.async_job_id is returned,
    you'll need to call check_share_job_status until
    the action completes to get the metadata for
    the folder.
    Apps must have full Dropbox access to use this endpoint.
  • listReceivedFiles (actions As java.util.List, limit As long) As void
  • transferFolder (sharedFolderId As java.lang.String, toDropboxId As java.lang.String) As void
    Transfer ownership of a shared folder to a member of the shared
    folder. User must have AccessLevel.owneraccess to the shared
    folder to perform a transfer.
    Apps must have full Dropbox access to use this endpoint.
  • listFileMetadataBatch2 (files As java.util.List, actions As java.util.List) As void
    Returns shared file metadata.
  • relinquishFolderMembership (sharedFolderId As java.lang.String) As void
    The current user relinquishes their membership in the designated
    shared folder and will no longer have access to the folder. A
    folder owner cannot relinquish membership in their own folder.
    This will run synchronously if leave_a_copy is false, and
    asynchronously if leave_a_copy is true.
    Apps must have full Dropbox access to use this endpoint.
  • listFileMembers (fle As java.lang.String) As void
    Use to obtain the members who have been invited
    to a file, both inherited and uninherited members.
  • modifySharedLinkSettings2 (url As java.lang.String, settings As com.dropbox.core.v2.sharing.SharedLinkSettings, removeExpiration As boolean) As void
    Modify the shared link's settings. If the requested
    visibility conflict with the shared links policy of
    the team or the shared folder (in case the linked file
    is part of a shared folder) then the
    LinkPermissions.resolved_visibility of the returned
    SharedLinkMetadata will reflect the actual visibility
    of the shared link and the
    LinkPermissions.requested_visibility will reflect
    the requested visibility.
  • listFolderMembers2 (sharedFolderId As java.lang.String, actions As java.util.List) As void
    Returns shared folder membership by its folder ID.
    Apps must have full Dropbox access to use this endpoint.
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
A couple of very important features in @DonManfred new Dropbox V2 lib are UPLOAD and DOWNLOAD files. I like to share the code for both with examples:
B4X:
Dim MyImport, MyExport As String
            Dim MyPath=File.DirRootExternal, MyFile ="germany.txt" As String
            MyImport="/Import"   'dropbox server subfolder
            MyExport="/Export"   'dropbox server subfolder
           
            'TO UPLOAD A FILE: if autorename is set to true and uploaded file has same name,
            'but its content changed, the file is not overwritten: e.g.: germany (1).txt                               
            dbxFiles.upload(MyPath, MyFile, MyImport &"/" & MyFile,False,False)  
           
            'TO DOWNLOAD A FILE TO DEVICE:
            dbxFiles.download(MyExport & "/" & MyFile, MyPath, MyFile)
 

RafaelC

Member
Licensed User
I’m trying the DropboxV2V0.28 lib.

I have downloaded and copied the dropbox-core-sdk-2.1.2.jar and Jackson-core-2.7.4.jar as per your instructions
I have downloaded and installed the DropboxV2Example1-Auth.zip.
Compilation proceeds Ok but I get an error on line 43 – Activity.LoadLayout(“OAuth”)

Also, OAuth layout can not be opened in the Designer :
Error loading file - Unknown type: 12
upload_2016-12-19_20-5-32.png

What am I doing wrong?
 

MarcusPalladino

New Member
Licensed User
Longtime User
Error downloading and uploading, please help me.

dbxFiles.upload(MyPath, MyFile, MyImport &"/" & MyFile,False,False)

upload_2017-2-24_10-4-32.png
 

DonManfred

Expert
Licensed User
Longtime User
Error downloading and uploading, please help me.
Did you added the two additional jars to your additional libs folder successfully?
This is the only i can think where this could come from.

Additional to the provided Library (xml and jar) you need to download:
1. dropbox-core-sdk-2.1.2.jar. Copy the file to your additional libraries folder.
2. jackson-core-2.7.4.jar. Copy the file to your additional libraries folder.

The file in you error message is part of the dropbox-core-sdk-2.1.2.jar
 

Gavins

Member
Licensed User
Longtime User
What is the correct syntax for the files delete event please? I currently get 'java.lang.Exception: Sub dbxfiles_delete signature does not match expected signature.' using dbxFiles_Delete (success As Boolean, meta As FileMetadata, error As String).
 

DonManfred

Expert
Licensed User
Longtime User
I currently get 'java.lang.Exception: Sub dbxfiles_delete signature does not match expected signature.
The problem is that i raise the Event from the code but i forgot to declare the Event in the wrapper.

Try it with this version please.
 

Attachments

  • DropboxV2V0.27.zip
    147.1 KB · Views: 371

Gavins

Member
Licensed User
Longtime User
Thanks, but I'm still getting the same error. It seems to happen every other time the file is deleted. When it doesn't error, the FileMetaData is returned as null. The file is deleted either way.

Edit: The times is isn't failing are when the file isn't there to delete. It successfully deletes the file when present but still errors with 'java.lang.Exception: Sub dbxfiles_delete signature does not match expected signature.'. Should the FileMetaData in 'Sub dbxFiles_Delete (success As Boolean, meta As FileMetadata, error As String)' be DeletedFileMetaData ?
 
Last edited:

Gavins

Member
Licensed User
Longtime User
Any ideas please?

In an objective C version of my app using Api V1 I was able to check the revision of a file then upload with the parent revision to replace it. Using the SDK I seem to be stuck checking for the file and trying to delete it if it already exists - which I'm unable to do without an untrappable error at the moment.

Cheers, Gavin.
 

DonManfred

Expert
Licensed User
Longtime User
I wrote the lib in the early V2-stage. Maybe the V2 Api changed... At the time i wrote the lib it was not possible to use a revision when you UPLOAD a file. You could list all revisions of a file. Or restore a file using it´s revision.

I checked the documentation this morning and i found indicators on how to do it.

Need to investigate but i´m limited in time having these days
 

DonManfred

Expert
Licensed User
Longtime User
I checked the documentation this morning and i found indicators on how to do it.
Sadfully i was looking at the http documentation.

After checking the java code and Dropbox jar it looks that there is no method to upload a file using a revision.
Even not using a "Parent revision".



In the Uploadbuilder are only properties for AutoRenaming and for silent uploads (mute).
 
Top