我想把一个有元数据的文件上传到谷歌硬盘
以下是我的基本代码:
Sub DriveMultiUpload(Bytes As Byte(), Name As String)
SetAuthHeaders("https://www.googleapis.com/auth/drive")
Dim mp = New MultipartFormDataContent
mp.Add(New StringContent(Name), "name")
mp.Add(New ByteArrayContent(Bytes))
Dim pb = mp.ReadAsByteArrayAsync.Result
Headers("Content-Type") = "multipart/related"
Dim response As Byte()
Dim ret = New WebInfo(Of String)
Try
response = UploadData("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", "POST", pb)
Catch ex As WebException
If ex.Response IsNot Nothing Then ret.Result = New StreamReader(ex.Response.GetResponseStream).ReadToEnd
End Try
End Sub
内容类型错误。请使用多部分。
[顺便说一句,我试过在Fiddler中调试,但是
-
这个请求没有出现,
-
当Fiddler打开时,响应是空的]
但我发现奇怪的是,一旦uploaddata返回,标头就不再包含任何内容类型,所以这可能是问题所在?
请告知