UploadOperation class

Applies to Windows and Windows Phone

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++.


var uploadOperation = promise.operation;




The UploadOperation class has these types of members:


The UploadOperation class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

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.



The UploadOperation class has these properties.

PropertyAccess typeDescription


Read/writeGets and sets the cost policy for the upload.


Read-onlyGets a string value indicating the group the upload belongs to.


Read-onlyThis 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-onlyGets the method to use for the upload.


Read/writeGets or sets the transfer priority of this upload operation when within a BackgroundTransferGroup. Possible values are defined by BackgroundTransferPriority.


Read-onlyGets the current progress of the upload operation.


Read-onlyGets the URI to upload from.


Read-onlySpecifies the IStorageFile to upload.


Read-onlyGets the group that this upload operation belongs to.



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.


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.

        var upload = null;
        var promise = null;

        function UploadFile (uriString, file) {
            try {

                var uri = Windows.Foundation.Uri(uriString);
                var uploader = new Windows.Networking.BackgroundTransfer.BackgroundUploader();

                // Set a header, so the server can save the file (this is specific to the sample server).
                uploader.setRequestHeader("Filename", file.name);

                // Create a new upload operation.
                upload = uploader.createUpload(uri, file);

                // Start the upload and persist the promise to be able to cancel the upload.
                promise = upload.startAsync().then(complete, error, progress);
            } catch (err) {


Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]


Windows::Networking::BackgroundTransfer [C++]





See also

Quickstart: Upload a file
Background Transfer sample



© 2014 Microsoft