共用方式為


BackgroundTransferContentPart 類別

定義

表示多部分傳輸要求的內容部分。 每個 BackgroundTransferContentPart 物件都可以代表文字內容的單一字串或單一檔案承載,但不能同時代表這兩者。

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
繼承
Object Platform::Object IInspectable BackgroundTransferContentPart
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
應用程式功能
internetClient internetClientServer privateNetworkClientServer

範例

下列範例示範如何設定和開始多部分上傳作業。

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

建構函式

BackgroundTransferContentPart()

建立 BackgroundTransferContentPart 物件。

BackgroundTransferContentPart(String)

建立 BackgroundTransferContentPart 物件,識別它所代表的內容。

BackgroundTransferContentPart(String, String)

建立 BackgroundTransferContentPart 物件,識別其所代表的檔案內容和檔案名。

方法

SetFile(IStorageFile)

設定 BackgroundTransferContentPart 的來源檔案,其中包含要上傳的檔案。

SetHeader(String, String)

設定內容處置標頭值,指出這個 BackgroundTransferContentPart 所代表之資訊的本質。

SetText(String)

使用此方法可設定 BackgroundTransferContentPart 所代表的文字資訊。

適用於

另請參閱