Επεξεργασία

Κοινή χρήση μέσω


WebClient.UploadDataTaskAsync Method

Definition

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object. These methods do not block the calling thread.

Overloads

UploadDataTaskAsync(String, Byte[])

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

UploadDataTaskAsync(Uri, Byte[])

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

UploadDataTaskAsync(String, String, Byte[])

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

UploadDataTaskAsync(Uri, String, Byte[])

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

UploadDataTaskAsync(String, Byte[])

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<cli::array <System::Byte> ^> ^ UploadDataTaskAsync(System::String ^ address, cli::array <System::Byte> ^ data);
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (string address, byte[] data);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (string address, byte[] data);
member this.UploadDataTaskAsync : string * byte[] -> System.Threading.Tasks.Task<byte[]>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UploadDataTaskAsync : string * byte[] -> System.Threading.Tasks.Task<byte[]>
Public Function UploadDataTaskAsync (address As String, data As Byte()) As Task(Of Byte())

Parameters

address
String

The URI of the resource to receive the data.

data
Byte[]

The data buffer to send to the resource.

Returns

Task<Byte[]>

The task object representing the asynchronous operation. The Result property on the task object returns a Byte array containing the body of the response received from the resource when the data buffer was uploaded.

Attributes

Exceptions

The address parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

An error occurred while opening the stream.

-or-

There was no response from the server hosting the resource.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

This operation will not block. The returned Task<TResult> object will complete after the a data buffer has been uploaded to the resource.

This method sends a data buffer to a resource. The data buffer is sent asynchronously using thread resources that are automatically allocated from the thread pool. The data is not encoded.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

If the BaseAddress property is not an empty string (""), and address does not contain an absolute URI, address must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. If the QueryString property is not an empty string, it is appended to address.

This method uses the STOR command to upload an FTP resource. For an HTTP resource, the POST method is used.

Note

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in .NET Framework.

Applies to

UploadDataTaskAsync(Uri, Byte[])

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<cli::array <System::Byte> ^> ^ UploadDataTaskAsync(Uri ^ address, cli::array <System::Byte> ^ data);
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (Uri address, byte[] data);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (Uri address, byte[] data);
member this.UploadDataTaskAsync : Uri * byte[] -> System.Threading.Tasks.Task<byte[]>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UploadDataTaskAsync : Uri * byte[] -> System.Threading.Tasks.Task<byte[]>
Public Function UploadDataTaskAsync (address As Uri, data As Byte()) As Task(Of Byte())

Parameters

address
Uri

The URI of the resource to receive the data.

data
Byte[]

The data buffer to send to the resource.

Returns

Task<Byte[]>

The task object representing the asynchronous operation. The Result property on the task object returns a Byte array containing the body of the response received from the resource when the data buffer was uploaded.

Attributes

Exceptions

The address parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

An error occurred while opening the stream.

-or-

There was no response from the server hosting the resource.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

This operation will not block. The returned Task<TResult> object will complete after the a data buffer has been uploaded to the resource.

This method sends a data buffer to a resource. The data buffer is sent asynchronously using thread resources that are automatically allocated from the thread pool. The data is not encoded.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

If the BaseAddress property is not an empty string (""), and address does not contain an absolute URI, address must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. If the QueryString property is not an empty string, it is appended to address.

This method uses the STOR command to upload an FTP resource. For an HTTP resource, the POST method is used.

Note

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in .NET Framework.

Applies to

UploadDataTaskAsync(String, String, Byte[])

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<cli::array <System::Byte> ^> ^ UploadDataTaskAsync(System::String ^ address, System::String ^ method, cli::array <System::Byte> ^ data);
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (string address, string? method, byte[] data);
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (string address, string method, byte[] data);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (string address, string method, byte[] data);
member this.UploadDataTaskAsync : string * string * byte[] -> System.Threading.Tasks.Task<byte[]>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UploadDataTaskAsync : string * string * byte[] -> System.Threading.Tasks.Task<byte[]>
Public Function UploadDataTaskAsync (address As String, method As String, data As Byte()) As Task(Of Byte())

Parameters

address
String

The URI of the resource to receive the data.

method
String

The method used to send the data to the resource. If null, the default is POST for http and STOR for ftp.

data
Byte[]

The data buffer to send to the resource.

Returns

Task<Byte[]>

The task object representing the asynchronous operation. The Result property on the task object returns a Byte array containing the body of the response received from the resource when the data buffer was uploaded.

Attributes

Exceptions

The address parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

An error occurred while opening the stream.

-or-

There was no response from the server hosting the resource.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

This operation will not block. The returned Task<TResult> object will complete after the a data buffer has been uploaded to the resource.

This method sends a data buffer to a resource. The data buffer is sent asynchronously using thread resources that are automatically allocated from the thread pool. The data is not encoded.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

If the BaseAddress property is not an empty string (""), and address does not contain an absolute URI, address must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. If the QueryString property is not an empty string, it is appended to address.

Note

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in .NET Framework.

Applies to

UploadDataTaskAsync(Uri, String, Byte[])

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uploads a data buffer that contains a Byte array to the URI specified as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<cli::array <System::Byte> ^> ^ UploadDataTaskAsync(Uri ^ address, System::String ^ method, cli::array <System::Byte> ^ data);
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (Uri address, string? method, byte[] data);
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (Uri address, string method, byte[] data);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<byte[]> UploadDataTaskAsync (Uri address, string method, byte[] data);
member this.UploadDataTaskAsync : Uri * string * byte[] -> System.Threading.Tasks.Task<byte[]>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UploadDataTaskAsync : Uri * string * byte[] -> System.Threading.Tasks.Task<byte[]>
Public Function UploadDataTaskAsync (address As Uri, method As String, data As Byte()) As Task(Of Byte())

Parameters

address
Uri

The URI of the resource to receive the data.

method
String

The method used to send the data to the resource. If null, the default is POST for http and STOR for ftp.

data
Byte[]

The data buffer to send to the resource.

Returns

Task<Byte[]>

The task object representing the asynchronous operation. The Result property on the task object returns a Byte array containing the body of the response received from the resource when the data buffer was uploaded.

Attributes

Exceptions

The address parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

An error occurred while opening the stream.

-or-

There was no response from the server hosting the resource.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

This operation will not block. The returned Task<TResult> object will complete after the a data buffer has been uploaded to the resource.

This method sends a data buffer to a resource. The data buffer is sent asynchronously using thread resources that are automatically allocated from the thread pool. The data is not encoded.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

If the BaseAddress property is not an empty string (""), and address does not contain an absolute URI, address must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. If the QueryString property is not an empty string, it is appended to address.

Note

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in .NET Framework.

Applies to