I have a BackgroundUploader instance, with which i upload some files to a webdav server with put method. This works without any problem. Now in the BackgroundUploader namespace, there is a BackgroundTransferContentPart method, to upload multiple files. I cant figure out, how to do it the right way, because i have to add the filename to the URI, so that the file is put on the server. On BackgroundTransferContentPart, the URI is specified only once, without filename, so how can i do this multi files upload?
Edit: Here is my Code
private async void UploadAllFiles()
{
// URI
Uri uri = new Uri("https://example.com/upload/");
// FileOpenPicker
FileOpenPicker picker = new FileOpenPicker();
picker.FileTypeFilter.Add("*");
IReadOnlyList<StorageFile> files = await picker.PickMultipleFilesAsync();
// Files
List<BackgroundTransferContentPart> parts = new List<BackgroundTransferContentPart>();
for (int i = 0; i < files.Count; i++)
{
BackgroundTransferContentPart part = new BackgroundTransferContentPart("File" + i, files[i].Name);
part.SetFile(files[i]);
parts.Add(part);
}
// Credentials
string userName = "username";
string passWord = "password";
var creds = new PasswordCredential("login", userName, passWord);
// BG-Uploader
BackgroundUploader uploader = new BackgroundUploader();
uploader.SetRequestHeader("RequestId", file.DisplayName);
uploader.Method = "PUT";
uploader.ServerCredential = creds;
// Create operation
UploadOperation upload = await uploader.CreateUploadAsync(uri, parts);
// Upload
await upload.StartAsync().AsTask(cts.Token, progressCallback);
}