我正在使用Onedrive的“从URL上传项目”功能。 https://dev.onedrive.com/items/upload_url.htm
很多时候它都可行 - 过去几年我用这种方式上传了几千个文件。但是在过去的几天里,我一直在尝试批量上传大约4000个项目,而这个“从URL上传”并没有正常工作......
我在上传的9/10中看到的是,它接受了从URL上传请求,并返回一个“进度网址”进行监控,但该进度网址一直保持在“status = notStarted”状态“percentageComplete = 0%”,直到我在五分钟后放弃。
有没有人使用过URL上传功能?有任何经验吗?
我不认为这取决于速率限制。那是因为我停止了当天的代码,第二天重新启动它,并得到了同样的行为。
我想知道这个特定的目标文件名是否与上传错误有关?也许OneDrive处于一种奇怪的状态,它无法通过sideload上传到这个特定的文件名?
(我想我的下一次尝试是定期上传,看看会给出什么样的错误消息......)
' Initiate a sideload from the blobURL into OneDrive
Dim sideReqUrl = $"https://api.onedrive.com/v1.0/drive/root:{escapedFolder}:/children?access_token={accessToken}"
Dim sideReqContent = JsonConvert.SerializeObject(New JObject From {{"@content.sourceUrl", blobUrl}, {"@name.conflictBehavior", "fail"}, {"name", unescapedName}, {"file", New JObject}})
Dim sideReq As New HttpRequestMessage(HttpMethod.Post, sideReqUrl)
sideReq.Headers.Add("Prefer", "respond-async")
sideReq.Content = New StringContent(sideReqContent, Text.Encoding.UTF8, "application/json")
Dim sideResp = Await client.SendAsync(sideReq, cancel)
If sideResp.StatusCode <> Net.HttpStatusCode.Accepted Then
Console.WriteLine($"sideload rejected - {sideResp}")
Throw New Net.Http.HttpRequestException("sideload rejected")
End If
Dim progUrl = sideResp.Headers.Location ' for monitoring progress
Console.WriteLine($"sideload started - {progUrl}")
' Poll the progress of that sideload until it's complete
Do
Dim progResp = Await client.GetAsync(progUrl, cancel)
If progResp.StatusCode <> Net.HttpStatusCode.Accepted Then progResp.EnsureSuccessStatusCode()
Dim progRespText = Await progResp.Content.ReadAsStringAsync()
Dim progRespJson = JObject.Parse(progRespText)
If progResp.StatusCode = Net.HttpStatusCode.Accepted Then
Console.WriteLine($"sideload ping - {CStr(progRespJson("status"))} - {CStr(progRespJson("percentageComplete"))}%")
Continue Do
End If
Console.WriteLine("SIDELOAD COMPLETE!")
Return
Loop