我正嘗試使用其REST API將文件上傳到OneDrive。這就是我要完成的基礎上提供的文檔在OneDrive Rest API:使用REST API將文件上傳到Onedrive
POST https://apis.live.net/v5.0/me/skydrive/files?access_token=ACCESS_TOKEN
Content-Type: multipart/form-data; boundary=A300x
--A300x
Content-Disposition: form-data; name="file"; filename="HelloWorld.txt"
Content-Type: application/octet-stream
Hello, World!
--A300x--
這是我有:
Uri destination = new Uri(string.Format("https://apis.live.net/v5.0/{0}/files?", folder.ID));
BackgroundUploader uploader = new BackgroundUploader();
uploader.SetRequestHeader("Authorization", "Bearer " + account.AccessToken);
uploader.SetRequestHeader("Content-Type", "multipart/form-data; boundary=\"foo_bar_baz\"");
List<BackgroundTransferContentPart> parts = new List<BackgroundTransferContentPart>();
BackgroundTransferContentPart metaDataPart = new BackgroundTransferContentPart();
metaDataPart.SetHeader("Content-Disposition", "form-data; name=\"file\";filename=\""+content.Name+"\"");
parts.Add(metaDataPart);
BackgroundTransferContentPart contentPart = new BackgroundTransferContentPart();
contentPart.SetHeader("Content-Type", content.ContentType);
// content is a StorageFile
contentPart.SetFile(content);
response.UploadOperation = await uploader.CreateUploadAsync(destination, parts, "form-data", "foo_bar_baz");
這條線之下會導致訪問衝突錯誤和Windows應用商店應用程序崩潰:
response.UploadOperation = await uploader.CreateUploadAsync(destination, parts, "form-data", "foo_bar_baz");
您是否嘗試在代碼周圍放置try/catch塊以查看是否引發了任何異常? – kiewic 2014-10-02 00:26:03
異常來自cpp文件(背景api),並未捕獲(異常e)塊。有一個嘗試繞過這整個代碼。 – 2014-10-02 00:51:19
提琴手或網絡監視器跟蹤怎麼樣? – kiewic 2014-10-02 04:50:37