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
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(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)
var backgroundTransferContentPart = new backgroundTransferContentPart(name);
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)
var backgroundTransferContentPart = new backgroundTransferContentPart(name, fileName);
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
backgroundTransferContentPart.setFile(value);
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
backgroundTransferContentPart.setHeader(headerName, headerValue);
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
backgroundTransferContentPart.setText(value);
Parameters
value
Platform::String String String String

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