You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

tritnguyen's avatar
tritnguyen
Explorer | Level 3
3 years ago

Event log and delete folder.

Hi All,

I want to write a tool that keep track all the team members and their files on Dropbox. The information needs to be updated in 5 minutes interval. If a member adds a file, delete a file or rename the file, my tool will add/delete/update that file on the file list. Currently if the member adds a folder, my file list is updated correctly because Dropbox Java SDK sent out one event for each file in the folder. For example, it the folder has 3 files: f1.txt, f2.txt, and f3.txt, there will be 3 events to be sent. However, if the member delete a folder, there only one event to be sent; that event is for the folder, not for an individual file as the json below:

 

{
"timestamp" : "2022-11-04T04:10:55Z",
"event_category" : "file_operations",
"event_type" : {
".tag" : "file_delete",
"description" : "Deleted files and/or folders"
},
"details" : {
".tag" : "file_delete_details"
},
"actor" : {
".tag" : "admin",
"admin" : {
".tag" : "team_member",
"account_id" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"display_name" : "Test Admin",
"email" : "testAdmin@test.com",
"team_member_id" : "test_admin_team_member_id"
}
},
"origin" : {
"access_method" : {
".tag" : "end_user",
"end_user" : {
".tag" : "web",
"session_id" : "session_id"
}
},
"geo_location" : {
"ip_address" : "",
"city" : "",
"region" : "",
"country" : ""
}
},
"involve_non_team_member" : false,
"context" : {
".tag" : "team_member",
".tag" : "team_member",
"account_id" : "account_id",
"display_name" : "Test Admin",
"email" : "testAdmin@test.com",
"team_member_id" : "test_admin_team_member_id"
},
"participants" : [ ],
"assets" : [ {
".tag" : "folder",
"path" : {
"namespace_relative" : {
"ns_id" : "xxxxxxxxxxxxx",
"relative_path" : "/TestFolder/SubTestFolder",
"is_shared_namespace" : false
},
"contextual" : "/TestFolder/SubTestFolder"
},
"display_name" : "SubTestFolder",
"file_id" : "sub_test_folder_file_id",
"file_size" : 44,
"file_count" : 4
} ]
}

 

I want to update my file list correctly; I want to remove f1.txt, f2.txt, and f3.txt from my list after I got the event above; what do I need to do?

Thank you.

  • Greg-DB's avatar
    Greg-DB
    3 years ago

    tritnguyen To confirm what Здравко is saying, on Dropbox the deletion of a parent includes the deletion of any children of that parent, so it may be helpful to construct your data model/storage to reflect that as well.

     

    See also, the /2/files/list_folder[/continue] for listing the contents of a folder, which also works that way.

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    tritnguyen wrote:

    ...

    I want to update my file list correctly; I want to remove f1.txt, f2.txt, and f3.txt from my list after I got ...


    Hi tritnguyen,

    What about if you re-organize you "file list" in a file/folder tree? 🤔 You can always get a list out from the tree (if needed) and are able handle all event recursively whenever needed (like in situation mentioned by you). 😉

    Hope this helps.

    • tritnguyen's avatar
      tritnguyen
      Explorer | Level 3

      The number of members in the company my tool is designed for may be huge. Develop the system to keep track all the folders and files for each member is time consuming, and I try to avoid that. Is there any quick and easy way to do the bookkeeping?

       

      Thanks. 

      • Здравко's avatar
        Здравко
        Legendary | Level 20

        tritnguyen wrote:

        ... Develop the system to keep track all the folders and files for each member is time consuming, and I try to avoid that. ...


        I don't know such a bookkeeping way, but tree data structure processing typically consumes significantly less time that equivalent list processing (logarithmic vs linear load), if structured properly. That's why much more suitable for big data set (bigger difference between logarithm and line). 🤷

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,884 PostsLatest Activity: 13 days ago
326 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!