OneDrive / onedrive-sdk-csharp

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

Update item use "Content" property throw exception #113

Closed jingliancui closed 8 years ago

jingliancui commented 8 years ago

Hello , I follow your docs' item doc :https://github.com/OneDrive/onedrive-sdk-csharp/blob/master/docs/items.md#moving-and-updating-an-item update the file it ok, but I update the Item's Content property with Stream,It's throw exception. Is it has other way for me to update the Item's Content which is stream.

ginach commented 8 years ago

@jingliancui, could you provide more details about what exception you're seeing?

jingliancui commented 8 years ago

@ginach ,There is the error message: The API 'System.IO.BufferedStream.get_CanRead()' cannot be used on the current platform. See http://go.microsoft.com/fwlink/?LinkId=248273 for more information.

My app's platform is the universal windows app. There is something image for you : Hope that message will help you

errormessage 3 1 2

ginach commented 8 years ago

This is a weird one but I'm not sure if it's a bug in our code or JSON.NET. I'll need to dig in further.

ginach commented 8 years ago

Ah, I see what's happening here. The update call you're making is to update item metadata. We don't actually support sending metadata and stream in that way on the service side. Instead, what you'll want to do is update item content using the /content navigation. For example:

var updatedItem =
    await this.oneDriveClient.Items[id].Content.Request().PutAsync<Item>(stream);

Also, you'll want the stream to be one that supports reading and seeking. For example, a file stream or memory stream.