如何将大文件上传到OneDrive?

时间:2019-08-28 10:37:34

标签: c# onedrive

我正在将大文件上传到OneDrive,但是我不知道如何执行此操作。现在,我获得了一个令牌,并成功创建了一个上传会话。我不知道如何将大文件分开,然后将其上传到服务器。

我正在使用restsharp库。

RestClient restClient = new RestClient("https://graph.microsoft.com/v1.0");
        RestRequest restRequest = new RestRequest(strPath);
        restRequest.RequestFormat = RestSharp.DataFormat.Json;
        restRequest.Method = Method.POST;
        restRequest.AddParameter("Authorization", string.Format("Bearer " + strToken), ParameterType.HttpHeader);

        restRequest.AddHeader("Authorization", "Authorization");
        restRequest.AddHeader("Content-Type", "application/json");

        restRequest.AddParameter("application/json", "{}", ParameterType.RequestBody);

        var response = restClient.Execute(restRequest);
        var myResult = response.StatusCode;
        if(response.StatusCode == System.Net.HttpStatusCode.OK)
        { 
            string strFileName = @"D:\\image.pdf";

            JObject jo = (JObject)JsonConvert.DeserializeObject(response.Content);
            string strUploadUrl = jo["uploadUrl"].ToString();
}

如果有任何代码片段,将不胜感激。

0 个答案:

没有答案