Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Provide information about Modifier to Metadata #16

Closed
danielkornev opened this issue Dec 14, 2014 · 3 comments
Closed

Provide information about Modifier to Metadata #16

danielkornev opened this issue Dec 14, 2014 · 3 comments

Comments

@danielkornev
Copy link

Since July 2014, Dropbox Core API supports Modifier data for files in personal accounts. This is available only to those apps that requested permission for that, but this is a very, very useful feature.

For now, I used the following approach:

  1. own method to obtain metadata
  2. own class with metadata
  3. method:

private async Task GetMetadataEx(string relativePath)
{
string webFilePath = relativePath.Replace("", "/");

        HttpClientHandler handler = new HttpClientHandler();

        // OAuth
        DropNetRT.Authentication.OAuthMessageHandler oauthHandler =
            new DropNetRT.Authentication.OAuthMessageHandler(handler, apiKey, apiSecret, client.UserLogin.Token, client.UserLogin.Secret);

        HttpClient c = new HttpClient(oauthHandler);

        string str = string.Format("https://api.dropbox.com/1/metadata/auto/{0}", webFilePath);

        HttpRequest httpRequest = new HttpRequest(HttpMethod.Get, str);

        // we don't need list
        httpRequest.Parameters.Add(new HttpParameter("list", (object)false));
        //httpRequest.Parameters.Add(new HttpParameter("include_deleted", (object)includeDeleted));

        // we need membership data
        httpRequest.Parameters.Add(new HttpParameter("include_membership", (object)true));

        HttpResponseMessage httpResponseMessage;
        oauthHandler.Authenticate(httpRequest);
        try
        {
            httpResponseMessage = await c.SendAsync(httpRequest);
        }
        catch (Exception exception)
        {
            //throw new DropboxException(exception);

            return null;
        }
        if (httpResponseMessage.StatusCode != HttpStatusCode.OK)
        {
            return null;
            //throw new DropboxException(httpResponseMessage);
        }

        string responseString = await httpResponseMessage.Content.ReadAsStringAsync();


        var metadataEx = JsonConvert.DeserializeObject<DropboxMetadataEx>(responseString);

        return metadataEx;
    }
  1. extended metadata class:

    public class DropboxMetadataEx : DropNetRT.Models.Metadata
    

    {
    [JsonProperty("modifier")]
    public Modifier Modifier
    {
    get;
    set;
    }

    } // class

    public class Modifier
    {
    [JsonProperty("display_name")]
    public string DisplayName { get; set; }
    [JsonProperty("uid")]
    public string Uid { get; set; }
    } // class

@danielkornev
Copy link
Author

https://www.dropbox.com/developers/core/docs#metadata

Heads up: The following fields relating to shared folders are in production beta. Please complete this form for access.

...

modifier
For files within a shared folder, this field specifies which user last modified this file. The value is a user dictionary with the fields uid (user ID), display_name, and, if the linked account is a member of a Dropbox for Business team, same_team (whether the user is on the same team as the linked account). If this endpoint is called by a Dropbox for Business app and the user is on that team, a member_id field will also be present in the user dictionary. If the modifying user no longer exists, the value will be null.

@dkarzon
Copy link
Member

dkarzon commented Dec 14, 2014

Thanks, I'll take a look at adding this to the existing GetMetadata function with an additional flag.

Do you know if it errors without permission or just doesn't return the modifier details?

@danielkornev
Copy link
Author

No idea, actually, Damian. I was busy crafting prototype for demo purposes, and thus didn't check that.

Sent from my Windows Phone


From: Damian Karzonmailto:notifications@github.com
Sent: ý12/ý14/ý2014 11:12 PM
To: DropNet/DropNetRTmailto:DropNetRT@noreply.github.com
Cc: Daniel Kornevmailto:daniel@zetuniverse.com
Subject: Re: [DropNetRT] Provide information about Modifier to Metadata (#16)

Thanks, I'll take a look at adding this to the existing GetMetadata function with an additional flag.

Do you know if it errors without permission or just doesn't return the modifier details?


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-66927625.

dkarzon added a commit that referenced this issue Dec 16, 2014
@dkarzon dkarzon closed this as completed Apr 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants