Reputation: 2289
I want to fetch the events related to my dropbox like I can see here , means I want to get when a particular file is added, changed, moved, deleted or renamed and by which user.
I have looked into the Webhooks docs. The webhook docs states the the response it sends to the callback url contails the userids, with which I can update the directory listing based on the webhook response for the user by calling the /delta.
But with it I cannot tell if there is an operation made for a file like a particular file has been renamed or deleted as since if I rename a file fro abc to xyz. If I get a response then I will look for the changes related to the file xyz which I will not find in my existing database so logically I will be making the events as deleted abc and added xyz, where as the reality is renamed abc to xyz.
It will be really grateful if you can help me regarding this.
Upvotes: 0
Views: 1197
Reputation: 95931
A file rename is reported as DeletedMetadata
followed by a FileMetadata
for the file.
What is annoying is that DeletedMetadata
do not contain the file .id
attribute, only .name
and .path
, while FileMetadata
include all attributes (.id
same as before any deletions/renames, updated .name
and .path
).
So you should have a local mapping connecting names/paths and IDs in order to know which file got deleted (when only DeletedMetadata
is received) or renamed (when both DeletedMetadata
and FileMetadata
are received).
Upvotes: 0
Reputation: 60143
There's no real way to detect a rename (versus a delete and an add) via the Dropbox API. You can use heuristics (like whether the new file has the same contents as the old file and was created around the same time as the old file was deleted), but those are just going to be guesses with varying levels of accuracy.
Also, there's currently no way via the API to see which user modified a file in a shared folder.
UPDATE: The Core API now includes (in beta) the ability to see who last modified a file in a shared folder. See https://www.dropbox.com/developers/blog/101/new-in-beta-shared-folder-metadata.
Upvotes: 1