DriveClientUpdateFileAsync(FileInfo, String, ActionIUploadProgress, CancellationToken) Method
Asynchronously updates (replaces) a existing 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 Task<KeyValuePair<ResumableUpload, File>> UpdateFileAsync(
FileInfo srcFile,
string dstFileId,
Action<IUploadProgress> progressHandler,
CancellationToken cancellationToken
)
Public Function UpdateFileAsync (
srcFile As FileInfo,
dstFileId As String,
progressHandler As Action(Of IUploadProgress),
cancellationToken As CancellationToken
) As Task(Of KeyValuePair(Of ResumableUpload, File))
Dim instance As DriveClient
Dim srcFile As FileInfo
Dim dstFileId As String
Dim progressHandler As Action(Of IUploadProgress)
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of KeyValuePair(Of ResumableUpload, File))
returnValue = instance.UpdateFileAsync(srcFile,
dstFileId, progressHandler, cancellationToken)
public:
Task<KeyValuePair<ResumableUpload^, File^>>^ UpdateFileAsync(
FileInfo^ srcFile,
String^ dstFileId,
Action<IUploadProgress^>^ progressHandler,
CancellationToken cancellationToken
)
member UpdateFileAsync :
srcFile : FileInfo *
dstFileId : string *
progressHandler : Action<IUploadProgress> *
cancellationToken : CancellationToken -> Task<KeyValuePair<ResumableUpload, File>>
No code example is currently available or this language may not be supported.
- srcFile FileInfo
-
The source file to upload.
- dstFileId String
-
The identifier of the existing file being updated.
- progressHandler ActionIUploadProgress
-
A event handler that will receive progress changes of the upload operation.
- cancellationToken CancellationToken
-
A cancellation token to cancel the upload operation.
TaskKeyValuePairResumableUpload,
File
The resulting
TaskTResult.
This is a code example.
No code example is currently available or this language may not be supported.
Private Async Sub UpdateFile()
Dim client As New DriveClient("C:\GoogleSecrets.json", "yourmail@gmail.com", DriveScopes.Full)
Dim credential As UserCredential = Await client.AuthorizeAsync()
Dim srcFile As New FileInfo("C:\File.ext")
Dim result As KeyValuePair(Of Google.Apis.Upload.ResumableUpload, Google.Apis.Drive.v3.Data.File) =
Await client.UpdateFileAsync(srcFile, "Existing File Id.", AddressOf Me.Upload_ProgressChanged, Nothing)
Dim sb As New Global.System.Text.StringBuilder()
With sb
.AppendLine(String.Format("Id: {0}", result.Value.Id))
.AppendLine(String.Format("Name: {0}", result.Value.Name))
.AppendLine(String.Format("Size: {0}", result.Value.Size))
.AppendLine(String.Format("MIME type: {0}", result.Value.MimeType))
.AppendLine(String.Format("Date Created: {0}", result.Value.CreatedTime?.ToString()))
.AppendLine(String.Format("Url: {0}", If(result.Value.WebContentLink, result.Value.WebViewLink)))
.AppendLine(String.Format("Parent Folder Ids: {0}", String.Join(",", If(result.Value.Parents, {"nul"}))))
End With
Console.WriteLine(sb.ToString())
End Sub
Public Sub Upload_ProgressChanged(ByVal e As Google.Apis.Upload.IUploadProgress)
Select Case e.Status
Case Google.Apis.Upload.UploadStatus.Starting
Console.WriteLine("Starting upload...")
Case Google.Apis.Upload.UploadStatus.Uploading
Console.WriteLine("Bytes sent: {0}", e.BytesSent)
Case Google.Apis.Upload.UploadStatus.Completed
Console.WriteLine("Upload completed.")
Case Google.Apis.Upload.UploadStatus.Failed
Console.WriteLine("Upload failed. Reason: {0}", e.Exception.Message)
Case Else
' Do Nothing.
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.