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

Provide information about Modifier to Metadata #16

Closed
@danielkornev

Description

@danielkornev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions