cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API - Getting owner information of a file that is not shared

API - Getting owner information of a file that is not shared

jerry14
Explorer | Level 4

Hi - I am trying to get owner information of a file that is not shared.  I tried the below - 

 

FileMetadata fileMetadata = (FileMetadata) dbxTeamClient.asAdmin(adminId).files().getMetadata(fileId);

 

But FileMetadata doesn't seem to have this information.  For shared files/folders, I am able to get same using sharing/list_file_members API. But the same API fails when  a non-shared fileId is passed to it.

 

This is for Team Space configuration and I am accessing the file with Admin credentials

 

Thanks

6 Replies 6

Здравко
Legendary | Level 20

Hi @jerry14,

You cannot get such information within FileMetadata just because there is no such info within. 🙂 You correctly referred to SharedFileMembers (despite indirectly), where you can get desired info. Such a result you can receive from DbxUserSharingRequests.listFileMembers(java.lang.String file).


@jerry14 wrote:

... But the same API fails when  a non-shared fileId is passed to it.

...


To be honest I have no idea what you are talking about here. 🤷 It's working as expected. What fails actually? 🤔 Can you post some code snippet able to reproduce the issue in a stable way? Describe expected output, actual output, and what exactly confuses you.

Greg-DB
Dropbox Staff

Files that aren't shared won't be explicitly listed as having an owner. Files that aren't shared are just implicitly considered to be owned by the user account that contains the files.

Здравко
Legendary | Level 20

@Greg-DB wrote:

Files that aren't shared won't be explicitly listed as having sharing information or an owner. ...


Yes, but this doesn't mean that listing shared members of particular file (even non shared) should fail! In such a case the owner will be the only listed user (or should be at least). Am I wrong?

By the way I asked already @jerry14, to provide some additional information, but spam filter seems caught my post (for whatever reason).

jerry14
Explorer | Level 4

Thanks for the response.  In that case, whats the best way to find the owner information using the APIs? I checked the metadata and other file related APIs to see if I can get the information. I couldn't find any or I must have missed something.  I need this because I am accessing files that belongs to different members using admin credentials and the connected member (admin member) is not the owner of the file.

 

 

Greg-DB
Dropbox Staff

If you've received a file ID from somewhere, it may be best to record the account that was associated when receiving that file ID. For example, if you are reading from the event log, and are taking the file ID from events about files there, you should also read out and save the account ID for the associated account from the event information.

 

If you only have the file ID though and don't know what account on the team it corresponds to, you should be able to get the account ID from FileSharingInfo.getModifiedBy() in the returned FileMetadata.getSharingInfo(), e.g., on the FileMetadata returned by getMetadata as in your example, even if it's not in a shared/team folder. (The "Sharing" term is a bit of a misnomer in this case; it would be set though because you're accessing the file information from another account via the admin access.)

 

You can look up the account information for the account ID using getAccount. You'd need to use asMember for that instead of asAdmin though.


The team space itself is just considered owned by the team, not a specific user.

jerry14
Explorer | Level 4

Its not an issue, but I was looking for the right/best way to find users/groups that has access to a list of files. 

 

Below are the steps:

 

a.  The list of files (fileIds) in a Business Account (with Teamspace config) is fetched first using list_folder/list_folder_continue APIs. The authenticating user is Admin for the business account. The list includes private (non shared) files as well belonging different members in the account.

b.  Now, with each of these fileIds, I was trying to fetch sharing info with the sharing/list_file_members API.  I was able to get details for all files in team/shared folders with this. 

c.  As sharing info was not available for private files, I was looking at Metadata for "owner" information, however thats not directly available in Metadata or sharing info. 

 

I followed what @Greg-DB suggested, and below are the 3 cases depending on the file ownership/sharing status

 

1.   For files in shared/team folders -> sharing/list_file_members API gives the information. No issues here.

2.  For files that are private and belonging to members other than authenticated user  -> sharing/list_file_members API gives sharing info -> and from that, modified by field gives the account Id. With the account id, I am getting account info and finding the team member id (owner)

3.  For files that are private and belonging to current authenticated user (in my case, the admin user) -> unlike case (2) sharing info is NULL in the response to sharing/list_file_members. In this case, I already know the admin user's member Id. So, assigning that as the owner.

 

I am not sure if the approaches followed in (2) and (3) are the right/best way since it involves multiple API calls to get the owner/access information. 

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    jerry14 Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?