Post 谷歌硬盘上传多部分错误
我正试图上传一个带有元数据的文件到谷歌硬盘 这是我的基本代码:Post 谷歌硬盘上传多部分错误,post,google-api,http-headers,webclient,Post,Google Api,Http Headers,Webclient,我正试图上传一个带有元数据的文件到谷歌硬盘 这是我的基本代码: 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")
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中调试,但是
请告知答案似乎只是不要使用
MultipartFormDataContent
相反,我在这里是基于这个代码的
像符咒一样有效一个特殊的原因是你自己做而不是使用图书馆?这可能对你好有帮助。我尝试将外部依赖项/库/包降至最低。hi。有人知道内容类型消失的原因/方式吗?