OneDrive / onedrive-sdk-csharp

OneDrive SDK for C#! https://dev.onedrive.com
Other
294 stars 143 forks source link

set custom metadata to files #131

Closed ShwetankSaraf closed 8 years ago

ShwetankSaraf commented 8 years ago

I need to try setting custom properties to files in onedrive. I think /update API may help for this. What things we need to set/get custom properties to onedrive files?

ginach commented 8 years ago

Hi @ShwetankSaraf,

You might want to check out the API documentation for custom metadata. Essentially, you'll need to register the schema for your metadata then it can be passed to the API just like any other facet on the item.

To pass additional data via the SDK, you can add the custom value to the AdditionalData dictionary on an item when you send it via AddAsync or UpdateAsync. For example:

var folderToCreate = new Item
{
    Name = "folder name",
    Folder = new Folder(),
    AdditionalData = new Dictionary<string, object>
    {
        { "customFacet", new CustomFacet { Name = "value" } }
    }
};

var newFolder = await client.Drive.Items[parentId].Children.Request().AddAsync(folderToCreate);
ShwetankSaraf commented 8 years ago

Thanks. I assume I need to register customFacet first by sending client ID and schema. parentId - > folder under this files will be created Here 'clinet' stands for ?