0

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);
    }
andy
  • 509
  • 1
  • 8
  • 21
  • could you please add your code to see what happened? – Nuri YILMAZ Apr 12 '16 at 16:44
  • sure, i have added my Code. As i wrote above, the upload works, but i have no idea, how to write all the files, if i dont give a filename to the URI. – andy Apr 12 '16 at 17:11
  • Is it even possible, to upload multiple files within one request to a webdav Server? – andy Apr 13 '16 at 17:37

0 Answers0