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

public : sealed class UploadOperation : IBackgroundTransferOperation, IBackgroundTransferOperationPriority
struct winrt::Windows::Networking::BackgroundTransfer::UploadOperation : IBackgroundTransferOperation, IBackgroundTransferOperationPriority
public sealed class UploadOperation : IBackgroundTransferOperation, IBackgroundTransferOperationPriority
Public NotInheritable Class UploadOperation Implements IBackgroundTransferOperation, IBackgroundTransferOperationPriority
// This class does not provide a public constructor.

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
internetClientServer privateNetworkClientServer internetClient


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) {

        using Windows.Foundation; 
        using Windows.Networking.BackgroundTransfer;
        using Windows.Storage.Pickers;
        using Windows.Storage;

        private async void StartUpload_Click(object sender, RoutedEventArgs e)
                Uri uri = new Uri(serverAddressField.Text.Trim());
                FileOpenPicker picker = new FileOpenPicker();
                StorageFile file = await picker.PickSingleFileAsync();

                BackgroundUploader uploader = new BackgroundUploader();
                uploader.SetRequestHeader("Filename", file.Name);

                UploadOperation upload = uploader.CreateUpload(uri, file);

                // Attach progress and completion handlers.
                HandleUploadAsync(upload, true);
            catch (Exception ex)
                LogException("Upload Error", ex);


After app termination, an app should enumerate all existing UploadOperation instances at next start-up using GetCurrentUploadsAsync. When a UWP 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 Microsoft 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.

Version history

Windows version SDK version Value added
1803 17134 MakeCurrentInTransferGroup


CostPolicy CostPolicy CostPolicy CostPolicy CostPolicy

Gets and sets the cost policy for the upload.

Group Group Group Group Group


Group may be altered or unavailable for releases after Windows 8.1. Instead, use TransferGroup.

Gets a string value indicating the group the upload belongs to.

Guid Guid Guid Guid Guid

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.

Method Method Method Method Method

Gets the method to use for the upload.

Priority Priority Priority Priority Priority

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

Progress Progress Progress Progress Progress

Gets the current progress of the upload operation.

RequestedUri RequestedUri RequestedUri RequestedUri RequestedUri

Gets the URI to upload from.

SourceFile SourceFile SourceFile SourceFile SourceFile

Specifies the IStorageFile to upload.

TransferGroup TransferGroup TransferGroup TransferGroup TransferGroup

Gets the group that this upload operation belongs to.


AttachAsync() AttachAsync() AttachAsync() AttachAsync() 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() GetResponseInformation() GetResponseInformation() GetResponseInformation() GetResponseInformation()

Gets the response information.

GetResultStreamAt(UInt64) GetResultStreamAt(UInt64) GetResultStreamAt(UInt64) GetResultStreamAt(UInt64) GetResultStreamAt(UInt64)

Gets the partially uploaded response at the specified location.

MakeCurrentInTransferGroup() MakeCurrentInTransferGroup() MakeCurrentInTransferGroup() MakeCurrentInTransferGroup() MakeCurrentInTransferGroup()

Prioritizes the upload transfer operation (and any transfers that follow it in the same transfer group). Calling this method on a transfer that doesn't belong to a transfer group has no effect.

StartAsync() StartAsync() StartAsync() StartAsync() StartAsync()

Starts an asynchronous upload operation.

See also