Windows 8.1 でBackgroundUploaderを介してMultipart/related Content-Type を使用してファイルをアップロードしたい
私のコードは次のとおりです
BackgroundUploader uploader = new BackgroundUploader();
uploader.SetRequestHeader("Content-Type", "multipart/related; boundary=foo_bar_baz");
uploader.Method = "POST";
// Create upload content
List<BackgroundTransferContentPart> parts = new List<BackgroundTransferContentPart>();
// File metadata
var part = new BackgroundTransferContentPart();
part.SetHeader("Content-Type", "text/plain");
part.SetText(file.DisplayName);
parts.Add(part);
// File
// Here file is of type StorageFile
part = new BackgroundTransferContentPart();
part.SetHeader("Content-Type", file.ContentType);
part.SetFile(file);
parts.Add(part);
UploadOperation upload = await uploader.CreateUploadAsync(new Uri("upload_url",UriKind.Absolute), parts);
await upload.StartAsync().AsTask(cts.token); // cts is CancellationTokenSource
ただし、このコードを実行すると、次のような例外が発生します
WinRT 情報: 'boundary': 'Content-Type' ヘッダーが設定されている場合、境界を空にすることはできず、'Content-Type' ヘッダーに設定されている境界と一致する必要があります。
私のコードで間違っている/欠けているものは何ですか?