Click or drag to resize

WikiSiteExtensionsUploadAsync(WikiSite, String, WikiUploadSource, String, Boolean, AutoWatchBehavior, CancellationToken) Method

This is preliminary documentation and is subject to change.

Asynchronously uploads a file in this title.

Namespace: WikiClientLibrary.Files
Assembly: WikiClientLibrary (in WikiClientLibrary.dll) Version: 0.9.0-int.2+447d1d590e6726b7881f750a0a0e42908f3e417e
Syntax
public static Task<UploadResult> UploadAsync(
	this WikiSite site,
	string title,
	WikiUploadSource source,
	string? comment,
	bool ignoreWarnings,
	AutoWatchBehavior watch,
	CancellationToken cancellationToken
)

Parameters

site  WikiSite
title  String
source  WikiUploadSource
Source of the file.
comment  String
Comment of the upload, as well as the page content if it doesn't exist.
ignoreWarnings  Boolean
Ignore any warnings. This must be set to upload a new version of an existing image.
watch  AutoWatchBehavior
Whether to add the file into your watchlist.
cancellationToken  CancellationToken
The cancellation token that will be checked prior to completing the returned task.

Return Value

TaskUploadResult
An UploadResult. You need to check ResultCode for further action.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type WikiSite. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
UnauthorizedAccessExceptionYou do not have the permission to upload the file.
OperationFailedException There's an general failure while uploading the file. - or - Since MW 1.31, if you are uploading the exactly same content to the same title with ignoreWarnings set to true, you will receive this exception with ErrorCode set to fileexists-no-change. See gerrit:378702.
TimeoutExceptionTimeout specified in Timeout has been reached.
See Also