DriveClientUploadFile(FileInfo, String) Method
Uploads a file in the specified folder.
Namespace: DevCase.ThirdParty.Google.DriveAssembly: DevCase.net48.ThirdParty.GoogleServices (in DevCase.net48.ThirdParty.GoogleServices.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public KeyValuePair<ResumableUpload, File> UploadFile(
FileInfo srcFile,
params string[] parentFolderIds
)
Public Function UploadFile (
srcFile As FileInfo,
ParamArray parentFolderIds As String()
) As KeyValuePair(Of ResumableUpload, File)
Dim instance As DriveClient
Dim srcFile As FileInfo
Dim parentFolderIds As String()
Dim returnValue As KeyValuePair(Of ResumableUpload, File)
returnValue = instance.UploadFile(srcFile,
parentFolderIds)
public:
KeyValuePair<ResumableUpload^, File^> UploadFile(
FileInfo^ srcFile,
... array<String^>^ parentFolderIds
)
member UploadFile :
srcFile : FileInfo *
parentFolderIds : string[] -> KeyValuePair<ResumableUpload, File>
No code example is currently available or this language may not be supported.
- srcFile FileInfo
-
The source file to upload.
- parentFolderIds String
-
The identifier of the parent folder(s) where to upload the file.
This paramenter can be empty (nul).
KeyValuePairResumableUpload,
File
The resulting
KeyValuePairTKey, TValue.
This is a code example.
No code example is currently available or this language may not be supported.
Private Sub UploadFile()
Dim client As New DriveClient("C:\GoogleSecrets.json", "yourmail@gmail.com", DriveScopes.Full)
Dim credential As UserCredential = client.Authorize()
Dim srcFile As New FileInfo("C:\File.ext")
Dim dstFolder As Google.Apis.Drive.v3.Data.File = client.GetFoldersByName("Folder Name").Single()
Dim result As KeyValuePair(Of Google.Apis.Upload.ResumableUpload, Google.Apis.Drive.v3.Data.File) =
client.UploadFile(srcFile, dstFolder.Id)
Dim upload As Global.Google.Apis.Upload.ResumableUpload = result.Key
Select Case upload.GetProgress().Status
Case Global.Google.Apis.Upload.UploadStatus.Failed
Console.WriteLine("Upload Failed.")
' To-Do: Retry/Resume Upload?:
' upload.Upload()
' upload.Resume()
Case Global.Google.Apis.Upload.UploadStatus.Completed
Dim dstFile As Global.Google.Apis.Upload.ResumableUpload = result.Value
Dim sb As New Global.System.Text.StringBuilder()
With sb
.AppendLine(String.Format("Id: {0}", dstFile.Id))
.AppendLine(String.Format("Name: {0}", dstFile.Name))
.AppendLine(String.Format("Size: {0}", dstFile.Size))
.AppendLine(String.Format("MIME type: {0}", dstFile.MimeType))
.AppendLine(String.Format("Date Created: {0}", dstFile.CreatedTime?.ToString()))
.AppendLine(String.Format("Url: {0}", If(dstFile.WebContentLink, dstFile.WebViewLink)))
.AppendLine(String.Format("Parent Folder Ids: {0}", String.Join(",", If(dstFile.Parents, {"nul"}))))
End With
Console.WriteLine(sb.ToString())
End Select
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.