Condividi tramite


BackgroundTransferContentPart Classe

Definizione

Rappresenta una parte del contenuto di una richiesta di trasferimento a più parti. Ogni oggetto BackgroundTransferContentPart può rappresentare una singola stringa di contenuto di testo o un singolo payload di file, ma non entrambi.

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
Ereditarietà
Object Platform::Object IInspectable BackgroundTransferContentPart
Attributi

Requisiti Windows

Famiglia di dispositivi
Windows 10 (è stato introdotto in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v1.0)
Funzionalità dell'app
internetClient internetClientServer privateNetworkClientServer

Esempio

Nell'esempio seguente viene illustrato come configurare e avviare un'operazione di caricamento a più parti.

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

Costruttori

BackgroundTransferContentPart()

Crea un oggetto BackgroundTransferContentPart .

BackgroundTransferContentPart(String)

Crea un oggetto BackgroundTransferContentPart che identifica il contenuto rappresentato.

BackgroundTransferContentPart(String, String)

Crea un oggetto BackgroundTransferContentPart che identifica il contenuto del file e il nome del file che rappresenta.

Metodi

SetFile(IStorageFile)

Imposta il file di origine per backgroundTransferContentPart contenente il file per il caricamento.

SetHeader(String, String)

Imposta i valori di intestazione di eliminazione del contenuto che indicano la natura delle informazioni rappresentate da BackgroundTransferContentPart .

SetText(String)

Usare questo metodo per impostare le informazioni di testo rappresentate da BackgroundTransferContentPart .

Si applica a

Vedi anche