public async Task <DavItem> Upload(Uri url, StorageFile file)
        {
            if (!url.IsAbsoluteUri)
            {
                url = new Uri(_serverUrl, url);
            }

            BackgroundUploader uploader = new BackgroundUploader();

            uploader.CostPolicy = ExecutionContext.Instance.IsBackgroundTask
                ? BackgroundTransferCostPolicy.UnrestrictedOnly
                : BackgroundTransferCostPolicy.Always;
            uploader.Method = "PUT";
            var buffer = CryptographicBuffer.ConvertStringToBinary(_credential.UserName + ":" + _credential.Password, BinaryStringEncoding.Utf8);
            var token  = CryptographicBuffer.EncodeToBase64String(buffer);
            var value  = new HttpCredentialsHeaderValue("Basic", token);

            uploader.SetRequestHeader("Authorization", value.ToString());

            var upload = uploader.CreateUpload(url, file);
            Progress <UploadOperation> progressCallback = new Progress <UploadOperation>(async operation => await OnUploadProgressChanged(operation));
            var task  = upload.StartAsync().AsTask(progressCallback);
            var task2 = await task.ContinueWith(OnUploadCompleted);

            return(await task2);
        }
        public List <UploadOperation> CreateUpload(DavItem item, List <StorageFile> files)
        {
            List <UploadOperation> result   = new List <UploadOperation>();
            BackgroundUploader     uploader = new BackgroundUploader();

            uploader.Method = "PUT";
            var buffer = CryptographicBuffer.ConvertStringToBinary(Configuration.UserName + ":" + Configuration.Password, BinaryStringEncoding.Utf8);
            var token  = CryptographicBuffer.EncodeToBase64String(buffer);
            var value  = new HttpCredentialsHeaderValue("Basic", token);

            uploader.SetRequestHeader("Authorization", value.ToString());
            foreach (var storageFile in files)
            {
                var uri = new Uri(item.EntityId.TrimEnd('/'), UriKind.RelativeOrAbsolute);
                uri = new Uri(uri + "/" + storageFile.Name, UriKind.RelativeOrAbsolute);
                if (!uri.IsAbsoluteUri)
                {
                    uri = CreateItemUri(uri);
                }
                UploadOperation upload = uploader.CreateUpload(uri, storageFile);
                result.Add(upload);
            }
            return(result);
        }