UploadOperation class
Performs an asynchronous upload operation. For an overview of Background Transfer capabilities, see Transferring data in the background. Download the Background Transfer sample for examples in JavaScript, C#, and C++.
Syntax
Public NotInheritable Class UploadOperation Inherits Object Implements IBackgroundTransferOperation
Attributes
- MarshalingBehaviorAttribute(Agile)
- VersionAttribute(NTDDI_WIN8)
Members
The UploadOperation class has these types of members:
Methods
The UploadOperation class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| AttachAsync | Returns an asynchronous operation that can be used to monitor progress and completion of the attached upload. Calling this method allows an app to attach upload operations that were started in a previous app instance. |
| GetResponseInformation | Gets the response information. |
| GetResultStreamAt | Gets the partially uploaded response at the specified location. |
| StartAsync | Starts an asynchronous upload operation. |
Properties
The UploadOperation class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read/write | Gets and sets the cost policy for the upload. | |
| Read-only | Gets a string value indicating the group the upload belongs to. | |
| Read-only | This is a unique identifier for a specific upload operation. A GUID associated to a upload operation will not change for the duration of the upload. | |
| Read-only | Gets the method to use for the upload. | |
| Read-only | Gets the current progress of the upload operation. | |
| Read-only | Gets the URI to upload from. | |
| Read-only | Specifies the IStorageFile to upload. |
Remarks
After app termination, an app should enumerate all existing UploadOperation instances at next start-up using GetCurrentUploadsAsync. When a Windows Store app using Background Transfer is terminated, incomplete uploads will persist in the background. If the app is restarted after termination and these incomplete operations are not enumerated and re-introduced to the current session, they will go stale and continue to occupy device resources.
Timeout considerations
-
1.) When establishing a new connection for an upload over TCP/SSL, the connection attempt is aborted if not established within five minutes.
-
2.) After the connection has been established, an HTTP request message that has not received a response within two minutes is aborted.
Assuming there is Internet connectivity, Background Transfer will retry an upload up to three times. In the event Internet connectivity is not detected, additional attempts will not be made until it is.
Debugging Guidance
Stopping a debugging session in Microsoft Visual Studio is comparable to closing your app; PUT uploads are paused and POST uploads are aborted. Even while debugging, your app should enumerate and then pause, restart, or cancel any persisted uploads.
However, if Visual Studio project updates, like changes to the app manifest, require that the app is uninstalled and re-deployed for debugging, GetCurrentUploadsAsync cannot enumerate persisted operations created using the previous app deployment.
Examples
The following example demonstrates how to configure and begin a basic upload operation, and is based on the Background Transfer sample offered in the Windows Sample Gallery.
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
|
Capabilities |
|
See also
Build date: 12/4/2012
