只需尝试恢复已中断的上传(已收到其上传URI)作为对InsertMediaUpload的 InitiateSessionAsync 方法的响应即可。但是ResumableUpload。 CreateFromUploadUri ()调用不会从中断的地方继续上传。
if (File.Exists(URIFile))
{
if (Uri.TryCreate(File.ReadAllText(URIFile), UriKind.Absolute, out uploadURI))
{
var credential = GoogleCredential.FromFile(adcPath);
var storage = StorageClient.Create(credential);
var filestream = new FileStream(filepath, FileMode.Open, FileAccess.Read);
if (filestream.CanSeek)
{
var ResumableUploadFromURI = ResumableUpload.CreateFromUploadUri(uploadURI, filestream, new ResumableUploadOptions()
{
ServiceName = "GcsSample"
});
progressBar1.Maximum = (int)filestream.Length;
ResumableUploadFromURI.ChunkSize = 262144;
ResumableUploadFromURI.ProgressChanged += OnUploadProgress;
ResumableUploadFromURI.ResumeAsync();
}
}
}