Compartilhar via


BackgroundTransferContentPart Classe

Definição

Representa uma parte de conteúdo de uma solicitação de transferência de várias partes. Cada objeto BackgroundTransferContentPart pode representar uma única cadeia de caracteres de conteúdo de texto ou uma única carga de arquivo, mas não ambas.

public ref class BackgroundTransferContentPart sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.Networking.BackgroundTransfer.IBackgroundTransferContentPartFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class BackgroundTransferContentPart final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(Windows.Networking.BackgroundTransfer.IBackgroundTransferContentPartFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class BackgroundTransferContentPart final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Networking.BackgroundTransfer.IBackgroundTransferContentPartFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class BackgroundTransferContentPart
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Networking.BackgroundTransfer.IBackgroundTransferContentPartFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class BackgroundTransferContentPart
function BackgroundTransferContentPart(name, fileName)
Public NotInheritable Class BackgroundTransferContentPart
Herança
Object Platform::Object IInspectable BackgroundTransferContentPart
Atributos

Requisitos do Windows

Família de dispositivos
Windows 10 (introduzida na 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduzida na v1.0)
Funcionalidades do aplicativo
internetClient internetClientServer privateNetworkClientServer

Exemplos

O exemplo a seguir demonstra como configurar e iniciar uma operação de carregamento de várias partes.

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);
    }
};

Construtores

BackgroundTransferContentPart()

Cria um objeto BackgroundTransferContentPart .

BackgroundTransferContentPart(String)

Cria um objeto BackgroundTransferContentPart que identifica o conteúdo que ele representa.

BackgroundTransferContentPart(String, String)

Cria um objeto BackgroundTransferContentPart que identifica o conteúdo do arquivo e o nome do arquivo que ele representa.

Métodos

SetFile(IStorageFile)

Define o arquivo de origem de um BackgroundTransferContentPart que contém o arquivo para upload.

SetHeader(String, String)

Define valores de cabeçalho de disposição de conteúdo que indicam a natureza das informações que este BackgroundTransferContentPart representa.

SetText(String)

Use esse método para definir informações de texto que o BackgroundTransferContentPart representa.

Aplica-se a

Confira também