コード例 #1
0
ファイル: OneDrive.cs プロジェクト: ywscr/ShareX
        private string CreateSession(string fileName)
        {
            string json = JsonConvert.SerializeObject(new
            {
                item = new Dictionary <string, string>
                {
                    { "@microsoft.graph.conflictBehavior", "replace" }
                }
            });

            string folderPath = GetFolderUrl(FolderID);

            string url = URLHelpers.BuildUri("https://graph.microsoft.com", $"/v1.0/{folderPath}:/{fileName}:/createUploadSession");

            AllowReportProgress = false;
            string response = SendRequest(HttpMethod.POST, url, json, RequestHelpers.ContentTypeJSON, headers: GetAuthHeaders());

            AllowReportProgress = true;

            OneDriveUploadSession session = JsonConvert.DeserializeObject <OneDriveUploadSession>(response);

            if (session != null)
            {
                return(session.uploadUrl);
            }

            return(null);
        }