BackgroundTransferContentPart BackgroundTransferContentPart BackgroundTransferContentPart BackgroundTransferContentPart BackgroundTransferContentPart Class

Definition

Represents a content part of a multi-part transfer request. Each BackgroundTransferContentPart object can represent either a single string of text content or a single file payload, but not both.

public : sealed class BackgroundTransferContentPart : IBackgroundTransferContentPart
struct winrt::Windows::Networking::BackgroundTransfer::BackgroundTransferContentPart : IBackgroundTransferContentPart
public sealed class BackgroundTransferContentPart : IBackgroundTransferContentPart
Public NotInheritable Class BackgroundTransferContentPart Implements IBackgroundTransferContentPart
var backgroundTransferContentPart = new backgroundTransferContentPart();
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
internetClientServer privateNetworkClientServer internetClient

Examples

The following example demonstrates how to configure and begin a multi-part upload operation, and is based on the Background Transfer sample offered in the Windows Sample Gallery.


        var upload = null;
        var promise = null;

        function MultipartUpload (uriString, files) {
            try {

                var uri = Windows.Foundation.Uri(uriString);
                var uploader = new Windows.Networking.BackgroundTransfer.BackgroundUploader();
                var contentParts = [];
                files.forEach(function (file, index) {
                    var part = new Windows.Networking.BackgroundTransfer.BackgroundTransferContentPart("File" + index, file.name);
                    part.setFile(file);
                    contentParts.push(part);
                });

                // Create a new upload operation.
                uploader.createUploadAsync(uri, contentParts).then(function (uploadOperation) {
                    // Start the upload and persist the promise to be able to cancel the upload.
                    upload = uploadOperation;
                    promise = uploadOperation.startAsync().then(complete, error, progress);
                });
            } catch (err) {
                displayError(err);
            }
        };

Constructors

BackgroundTransferContentPart() BackgroundTransferContentPart() BackgroundTransferContentPart() BackgroundTransferContentPart() BackgroundTransferContentPart()

Creates a BackgroundTransferContentPart object.

BackgroundTransferContentPart(String) BackgroundTransferContentPart(String) BackgroundTransferContentPart(String) BackgroundTransferContentPart(String) BackgroundTransferContentPart(String)

Creates a BackgroundTransferContentPart object that identifies the content it represents.

BackgroundTransferContentPart(String, String) BackgroundTransferContentPart(String, String) BackgroundTransferContentPart(String, String) BackgroundTransferContentPart(String, String) BackgroundTransferContentPart(String, String)

Creates a BackgroundTransferContentPart object that identifies the file content and the name of the file that it represents.

Methods

SetFile(IStorageFile) SetFile(IStorageFile) SetFile(IStorageFile) SetFile(IStorageFile) SetFile(IStorageFile)

Sets the source file for a BackgroundTransferContentPart containing the file for upload.

SetHeader(String, String) SetHeader(String, String) SetHeader(String, String) SetHeader(String, String) SetHeader(String, String)

Sets content disposition header values that indicate the nature of the information that this BackgroundTransferContentPart represents.

SetText(String) SetText(String) SetText(String) SetText(String) SetText(String)

Use this method to set text information that the BackgroundTransferContentPart represents.

See Also