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 : IBackgroundTransferContentPartpublic sealed class BackgroundTransferContentPart : IBackgroundTransferContentPartPublic NotInheritable Class BackgroundTransferContentPart Implements IBackgroundTransferContentPart
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
internetClientServer privateNetworkClientServer internetClient

Remarks

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

Creates a BackgroundTransferContentPart object.

public BackgroundTransferContentPart()public BackgroundTransferContentPart()Public Sub New()
Attributes

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

Creates a BackgroundTransferContentPart object that identifies the content it represents.

public BackgroundTransferContentPart(String name)public BackgroundTransferContentPart(String name)Public Sub New(name As String)
Parameters
name
System.String System.String System.String

Identifies the content.

Attributes

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.

public BackgroundTransferContentPart(String name, String fileName)public BackgroundTransferContentPart(String name, String fileName)Public Sub New(name As String, fileName As String)
Parameters
name
System.String System.String System.String

Identifies the content.

fileName
System.String System.String System.String

The fully qualified file name, including the local path.

Attributes

Methods

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

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

public void SetFile(IStorageFile value)public void SetFile(IStorageFile value)Public Function SetFile(value As IStorageFile) As void
Parameters
value
IStorageFile IStorageFile IStorageFile

The source file.

Attributes

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.

public void SetHeader(String headerName, String headerValue)public void SetHeader(String headerName, String headerValue)Public Function SetHeader(headerName As String, headerValue As String) As void
Parameters
headerName
System.String System.String System.String

The header name.

headerValue
System.String System.String System.String

The header value.

Attributes

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

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

public void SetText(String value)public void SetText(String value)Public Function SetText(value As String) As void
Parameters
value
System.String System.String System.String

A string value used to represent text information. (e.g. api_sig, api_key, auth_token, etc...)

Attributes