1
我試圖插入文件在谷歌驅動器使用webRequest(因爲我正在實施一個可恢復的異步上傳),但我不知道如何把數據放在請求「身體」 。插入文件到谷歌驅動器與Web請求
從現在開始,我有:
public static HttpWebRequest CreateUploadRequest(Google.Apis.Drive.v2.DriveService driveService, string uri, Stream contentStream, string title, string mimeType, string description = null)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "PUT";
Dictionary<string, object> requestBody = new Dictionary<string, object>();
requestBody["title"] = title;
requestBody["mimeType"] = mimeType;
if (!string.IsNullOrWhiteSpace(description))
{
requestBody["description"] = description;
}
driveService.Authenticator.ApplyAuthenticationToRequest(request);
Stream requestStream = request.GetRequestStream();
//How to do that???
requestStream.Close();
return request;
}
我設置了HttpWebRequest的頭,身體如何的數據應該被置於? 什麼是要插入的文件的byte []數據的屬性名稱?
任何例子,將不勝感激。