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 : IBackgroundTransferContentPartpublic sealed class BackgroundTransferContentPart : IBackgroundTransferContentPartPublic NotInheritable Class BackgroundTransferContentPart Implements IBackgroundTransferContentPart// You can use this class in JavaScript.
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(String) BackgroundTransferContentPart(String) BackgroundTransferContentPart(String) BackgroundTransferContentPart(String)

Creates a BackgroundTransferContentPart object that identifies the content it represents.

public : BackgroundTransferContentPart(PlatForm::String name)public BackgroundTransferContentPart(String name)Public Sub New(name As String)// You can use this method in JavaScript.
Parameters
name
PlatForm::String String String String

Identifies the content.

See Also

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.

public : BackgroundTransferContentPart(PlatForm::String name, PlatForm::String fileName)public BackgroundTransferContentPart(String name, String fileName)Public Sub New(name As String, fileName As String)// You can use this method in JavaScript.
Parameters
name
PlatForm::String String String String

Identifies the content.

fileName
PlatForm::String String String String

The fully qualified file name, including the local path.

See Also

Methods

SetFile(IStorageFile) 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// You can use this method in JavaScript.
Parameters

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.

public : void SetHeader(PlatForm::String headerName, PlatForm::String headerValue)public void SetHeader(String headerName, String headerValue)Public Function SetHeader(headerName As String, headerValue As String) As void// You can use this method in JavaScript.
Parameters
headerName
PlatForm::String String String String

The header name.

headerValue
PlatForm::String String String String

The header value.

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

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

public : void SetText(PlatForm::String value)public void SetText(String value)Public Function SetText(value As String) As void// You can use this method in JavaScript.
Parameters
value
PlatForm::String String String String

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