我尝试上传文件,但文件名为“untitle”。
byte[] fileBytes = System.IO.File.ReadAllBytes(fileName);
string UploadURI = String.Format("https://www.googleapis.com/upload/drive/v2/files?uploadType=media&access_token={0}", accessToken);
var request = (HttpWebRequest)HttpWebRequest.Create(UploadURI);
request.Method = "POST";
request.ContentLength = fileBytes.Length;
using (var dataStream = request.GetRequestStream())
{
dataStream.Write(fileBytes, 0, fileBytes.Length);
}
string status = (((HttpWebResponse)request.GetResponse()).StatusDescription);
if (status.ToLower() == "created" || status.ToLower()=="ok")
{
Uploaded = true;
}
如何将文件上传到特定文件夹?
答案 0 :(得分:0)
“untitle”和“parent folder”问题的答案是相同的。元数据。当你发布POST时,你应该提供一个包含标题的元数据对象:“title”和parent:[{id:“parent_id”}]