vb.net - 使用 vb.net 将大文件上传到谷歌驱动器
问题描述
我的代码仅适用于小于 5 mb 的文件,但是当我尝试使用更多 5 mb 的文件时出现异常。
Private Sub UploadFile()
If service.ApplicationName <> "Google Drive" Then CreateService()
Dim thefile As New File With {
.Name = fileName,
.Description = "A Backup File",
.MimeType = "application/octet-stream"
}
Dim uploadrequest As FilesResource.CreateMediaUpload
Dim bytearry As Byte() = System.IO.File.ReadAllBytes(filePath)
Try
Using stream = New System.IO.MemoryStream(bytearry, System.IO.FileMode.Open)
uploadrequest = service.Files.Create(thefile, stream, "application/octet-stream")
uploadrequest.Fields = "id"
'MsgBox(uploadrequest.GetProgress.Status.ToString())
uploadrequest.Upload()
End Using
Dim file As File = uploadrequest.ResponseBody
My.Settings.lastFileUploaded = fileName
Catch ex As Exception
MsgBox("error Upload Failed:" + ex.StackTrace)
End Try
MsgBox("upload Finished`enter code here` " + file.Id)enter code here
End Sub
解决方案
推荐阅读
- javascript - 是否可以在 Node 模块中导出动态导入?
- bash - 打开一个新的 git-bash 终端并在其中运行命令
- security - 如何在 Contiki / Cooja 模拟器中启用 LLSEC?
- node.js - 来自 tsconfig.json 的路径在 tsc 之后不起作用
- powerbi - DirectQuery PowerBI 中的 DAX 公式兼容性 - 匹配来自另一个表的值
- excel - VBA,IF逻辑错误,如何退出
- typedoc - 如何自定义 TypeDoc 主题?
- authentication - 如何在 Dynamics Crm 项目中更改 WS-Trust 安全性
- c# - 带有 cookie 的音频流 - 登录后 (C# NAudio)
- android - 如何使用 XML 在 Android 中创建此设计?