public async Task TestFileAttributesEncryptionAsync()
        {
            CloudFileShare share = GetRandomShareReference();

            try
            {
                await share.CreateIfNotExistsAsync();

                CloudFileDirectory directory = share.GetRootDirectoryReference();
                CloudFile          file      = directory.GetFileReference("file");
                await file.UploadTextAsync("test");

                await file.FetchAttributesAsync();

                Assert.IsTrue(file.Properties.IsServerEncrypted);

                CloudFile testFile = directory.GetFileReference(file.Name);
                await testFile.DownloadTextAsync();

                Assert.IsTrue(testFile.Properties.IsServerEncrypted);
            }
            finally
            {
                share.DeleteIfExistsAsync().Wait();
            }
        }
示例#2
0
        public void CloudFileDirectorySAS()
        {
            CloudFileDirectory dir  = this.testShare.GetRootDirectoryReference().GetDirectoryReference("dirfile");
            CloudFile          file = dir.GetFileReference("dirfile");

            dir.Create();
            file.Create(512);

            SharedAccessFilePolicy policy = new SharedAccessFilePolicy()
            {
                SharedAccessStartTime  = DateTimeOffset.UtcNow.AddMinutes(-5),
                SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30),
                Permissions            = SharedAccessFilePermissions.Read | SharedAccessFilePermissions.List
            };

            string             sasToken = file.GetSharedAccessSignature(policy);
            CloudFileDirectory sasDir   = new CloudFileDirectory(new Uri(dir.Uri.AbsoluteUri + sasToken));

            TestHelper.ExpectedException(
                () => sasDir.FetchAttributes(),
                "Fetching attributes of a directory using a file SAS should fail",
                HttpStatusCode.Forbidden);

            sasToken = this.testShare.GetSharedAccessSignature(policy);
            sasDir   = new CloudFileDirectory(new Uri(dir.Uri.AbsoluteUri + sasToken));
            sasDir.FetchAttributes();
        }
示例#3
0
        public async Task CloudFileDirectorySASAsync()
        {
            CloudFileDirectory dir  = this.testShare.GetRootDirectoryReference().GetDirectoryReference("dirfile");
            CloudFile          file = dir.GetFileReference("dirfile");

            await dir.CreateAsync();

            await file.CreateAsync(512);

            SharedAccessFilePolicy policy = new SharedAccessFilePolicy()
            {
                SharedAccessStartTime  = DateTimeOffset.UtcNow.AddMinutes(-5),
                SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30),
                Permissions            = SharedAccessFilePermissions.Read | SharedAccessFilePermissions.List
            };

            string             sasToken = file.GetSharedAccessSignature(policy);
            CloudFileDirectory sasDir   = new CloudFileDirectory(new Uri(dir.Uri.AbsoluteUri + sasToken));
            OperationContext   context  = new OperationContext();
            await TestHelper.ExpectedExceptionAsync(
                async() => await sasDir.FetchAttributesAsync(null /* accessCondition */, null /* options */, context),
                context,
                "Fetching attributes of a directory using a file SAS should fail",
                HttpStatusCode.Forbidden,
                "");

            sasToken = this.testShare.GetSharedAccessSignature(policy);
            sasDir   = new CloudFileDirectory(new Uri(dir.Uri.AbsoluteUri + sasToken));
            await sasDir.FetchAttributesAsync();
        }
示例#4
0
        public async Task CloudFileDirectoryWithFilesDeleteAsync()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            try
            {
                await share.CreateAsync();

                if (await CloudFileDirectorySetupAsync(share))
                {
                    CloudFileDirectory dir1    = share.GetRootDirectoryReference().GetDirectoryReference("TopDir1/MidDir1/EndDir1");
                    CloudFile          file1   = dir1.GetFileReference("EndFile1");
                    OperationContext   context = new OperationContext();
                    await TestHelper.ExpectedExceptionAsync(
                        async() => await dir1.DeleteAsync(null, null, context),
                        context,
                        "Delete a non-empty directory",
                        HttpStatusCode.Conflict);

                    await file1.DeleteAsync();

                    await dir1.DeleteAsync();

                    Assert.IsFalse(await file1.ExistsAsync());
                    Assert.IsFalse(await dir1.ExistsAsync());
                }
            }
            finally
            {
                share.DeleteAsync().Wait();
            }
        }
示例#5
0
        public async Task CloudFileDirectoryFileCreateWithoutDirectoryAsync()
        {
            CloudFileClient    client        = GenerateCloudFileClient();
            string             name          = GetRandomShareName();
            CloudFileShare     share         = client.GetShareReference(name);
            CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();

            try
            {
                await share.CreateAsync();

                CloudFileDirectory dir     = rootDirectory.GetDirectoryReference("Dir1");
                CloudFile          file    = dir.GetFileReference("file1");
                OperationContext   context = new OperationContext();
                await TestHelper.ExpectedExceptionAsync(
                    async() => await file.CreateAsync(0, null, null, context),
                    context,
                    "Creating a file when the directory has not been created should throw",
                    HttpStatusCode.NotFound,
                    "ParentNotFound");

                // File creation directly in the share should pass.
                CloudFile file2 = rootDirectory.GetFileReference("file2");
                await file2.CreateAsync(0);

                await dir.CreateAsync();

                await file.CreateAsync(0);
            }
            finally
            {
                share.DeleteAsync().Wait();
            }
        }
示例#6
0
        public void CloudFileDirectoryFileCreateWithoutDirectory()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            try
            {
                share.Create();
                CloudFileDirectory dir  = share.GetRootDirectoryReference().GetDirectoryReference("Dir1");
                CloudFile          file = dir.GetFileReference("file1");
                TestHelper.ExpectedException(
                    () => file.Create(0),
                    "Creating a file when the directory has not been created should throw",
                    HttpStatusCode.NotFound,
                    "ParentNotFound");

                // File creation directly in the share should pass.
                CloudFile file2 = share.GetRootDirectoryReference().GetFileReference("file2");
                file2.Create(0);

                dir.Create();
                file.Create(0);
            }
            finally
            {
                share.Delete();
            }
        }
示例#7
0
        public void CloudFileDirectoryWithFilesDelete()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            try
            {
                share.Create();
                if (CloudFileDirectorySetup(share))
                {
                    CloudFileDirectory dir1  = share.GetRootDirectoryReference().GetDirectoryReference("TopDir1/MidDir1/EndDir1");
                    CloudFile          file1 = dir1.GetFileReference("EndFile1");
                    TestHelper.ExpectedException(
                        () => dir1.Delete(),
                        "Delete a non-empty directory",
                        HttpStatusCode.Conflict);

                    file1.Delete();
                    dir1.Delete();
                    Assert.IsFalse(file1.Exists());
                    Assert.IsFalse(dir1.Exists());
                }
            }
            finally
            {
                share.Delete();
            }
        }
示例#8
0
 public static CloudFile GetFileReference(CloudFileDirectory parent, string path)
 {
     var filename = Path.GetFileName(path);
     var fullPath = Path.GetDirectoryName(path);
     if (fullPath == string.Empty)
     {
         return parent.GetFileReference(filename);
     }
     var dirReference = GetDirectoryReference(parent, fullPath);
     return dirReference.GetFileReference(filename);
 }
示例#9
0
        public void CloudFileShareReference()
        {
            CloudFileClient    client        = GenerateCloudFileClient();
            CloudFileShare     share         = client.GetShareReference("share");
            CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();
            CloudFileDirectory directory     = rootDirectory.GetDirectoryReference("directory4");
            CloudFile          file          = directory.GetFileReference("file2");

            Assert.AreEqual(share, file.Share);
            Assert.AreEqual(share, rootDirectory.Share);
            Assert.AreEqual(share, directory.Share);
            Assert.AreEqual(share, directory.Parent.Share);
            Assert.AreEqual(share, file.Parent.Share);
        }
示例#10
0
        public void CloudFileDirectoryWithFilesDeleteAPM()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            try
            {
                share.Create();
                if (CloudFileDirectorySetup(share))
                {
                    CloudFileDirectory dir1  = share.GetRootDirectoryReference().GetDirectoryReference("TopDir1/MidDir1/EndDir1");
                    CloudFile          file1 = dir1.GetFileReference("EndFile1");
                    using (AutoResetEvent waitHandle = new AutoResetEvent(false))
                    {
                        IAsyncResult result = dir1.BeginDelete(
                            ar => waitHandle.Set(),
                            null);
                        waitHandle.WaitOne();
                        TestHelper.ExpectedException(
                            () => dir1.EndDelete(result),
                            "Delete a non-empty directory",
                            HttpStatusCode.Conflict);

                        result = file1.BeginDelete(
                            ar => waitHandle.Set(),
                            null);
                        waitHandle.WaitOne();
                        file1.EndDelete(result);

                        result = dir1.BeginDelete(
                            ar => waitHandle.Set(),
                            null);
                        waitHandle.WaitOne();
                        dir1.EndDelete(result);
                    }

                    Assert.IsFalse(file1.Exists());
                    Assert.IsFalse(dir1.Exists());
                }
            }
            finally
            {
                share.Delete();
            }
        }
        public async Task CloudFileClientMaximumExecutionTimeoutAsync()
        {
            CloudFileClient    fileClient    = GenerateCloudFileClient();
            CloudFileShare     share         = fileClient.GetShareReference(Guid.NewGuid().ToString("N"));
            CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();

            byte[] buffer = FileTestBase.GetRandomBuffer(80 * 1024 * 1024);

            try
            {
                await share.CreateAsync();

                fileClient.DefaultRequestOptions.MaximumExecutionTime = TimeSpan.FromSeconds(5);

                CloudFile file = rootDirectory.GetFileReference("file");
                file.StreamWriteSizeInBytes = 1 * 1024 * 1024;
                using (MemoryStream ms = new MemoryStream(buffer))
                {
                    try
                    {
                        await file.UploadFromStreamAsync(ms);

                        Assert.Fail();
                    }
                    catch (AggregateException ex)
                    {
#if !FACADE_NETCORE
                        Assert.AreEqual("The client could not finish the operation within specified timeout.", RequestResult.TranslateFromExceptionMessage(ex.InnerException.Message).ExceptionInfo.Message);
#else
                        Assert.AreEqual("The client could not finish the operation within specified timeout.", RequestResult.TranslateFromExceptionMessage(ex.InnerException.Message).Exception.Message);
#endif
                    }
                    catch (TaskCanceledException)
                    {
                    }
                }
            }
            finally
            {
                fileClient.DefaultRequestOptions.MaximumExecutionTime = null;
                share.DeleteIfExistsAsync().Wait();
            }
        }
示例#12
0
        public async Task CloudFileApisInShareSnapshotAsync()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);
            await share.CreateAsync();

            CloudFileDirectory dir = share.GetRootDirectoryReference().GetDirectoryReference("dir1");
            await dir.CreateAsync();

            CloudFile file = dir.GetFileReference("file");
            await file.CreateAsync(1024);

            file.Metadata["key1"] = "value1";
            await file.SetMetadataAsync();

            CloudFileShare snapshot     = share.SnapshotAsync().Result;
            CloudFile      snapshotFile = snapshot.GetRootDirectoryReference().GetDirectoryReference("dir1").GetFileReference("file");

            file.Metadata["key2"] = "value2";
            await file.SetMetadataAsync();

            await snapshotFile.FetchAttributesAsync();

            Assert.IsTrue(snapshotFile.Metadata.Count == 1 && snapshotFile.Metadata["key1"].Equals("value1"));
            Assert.IsNotNull(snapshotFile.Properties.ETag);

            await file.FetchAttributesAsync();

            Assert.IsTrue(file.Metadata.Count == 2 && file.Metadata["key2"].Equals("value2"));
            Assert.IsNotNull(file.Properties.ETag);
            Assert.AreNotEqual(file.Properties.ETag, snapshotFile.Properties.ETag);

            CloudFile snapshotFile2 = new CloudFile(snapshotFile.SnapshotQualifiedStorageUri, client.Credentials);

            Assert.IsTrue(snapshotFile2.ExistsAsync().Result);
            Assert.IsTrue(snapshotFile2.Share.SnapshotTime.HasValue);

            await snapshot.DeleteAsync();

            await share.DeleteAsync();
        }
示例#13
0
        public void CloudFileClientObjects()
        {
            CloudFileClient fileClient = GenerateCloudFileClient();
            CloudFileShare  share      = fileClient.GetShareReference("share");

            Assert.AreEqual(fileClient, share.ServiceClient);
            CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();

            Assert.AreEqual(fileClient, rootDirectory.ServiceClient);
            CloudFileDirectory directory = rootDirectory.GetDirectoryReference("directory");

            Assert.AreEqual(fileClient, directory.ServiceClient);
            CloudFile file = directory.GetFileReference("file");

            Assert.AreEqual(fileClient, file.ServiceClient);

            CloudFileShare share2 = GetRandomShareReference();

            Assert.AreNotEqual(fileClient, share2.ServiceClient);
        }
        public async Task TestFileEncryptionAsync()
        {
            bool requestFound = false;

            OperationContext ctxt  = new OperationContext();
            CloudFileShare   share = GetRandomShareReference();

            try
            {
                await share.CreateIfNotExistsAsync();

                CloudFileDirectory directory = share.GetRootDirectoryReference();
                CloudFile          file      = directory.GetFileReference("file");

                await file.UploadTextAsync("test");

                ctxt.RequestCompleted += (sender, args) =>
                {
                    Assert.IsTrue(args.RequestInformation.IsRequestServerEncrypted);
                    requestFound = true;
                };

                await file.UploadTextAsync("test", null, null, ctxt);

                Assert.IsTrue(requestFound);

                requestFound = false;
                await file.SetPropertiesAsync(null, null, ctxt);

                Assert.IsTrue(requestFound);

                requestFound = false;
                await file.SetMetadataAsync(null, null, ctxt);

                Assert.IsTrue(requestFound);
            }
            finally
            {
                share.DeleteIfExistsAsync().Wait();
            }
        }
示例#15
0
        private void FileDirectoryEscapingTest(string directoryName, string fileName)
        {
            CloudFileClient service = GenerateCloudFileClient();
            CloudFileShare  share   = GetRandomShareReference();

            try
            {
                share.Create();
                string text = Guid.NewGuid().ToString();

                // Create from CloudFileShare.
                CloudFileDirectory directory = share.GetRootDirectoryReference().GetDirectoryReference(directoryName);
                directory.Create();
                CloudFile originalFile = directory.GetFileReference(fileName);
                originalFile.Create(0);

                // List directories from share.
                IListFileItem directoryFromShareListingFiles = share.GetRootDirectoryReference().ListFilesAndDirectories().First();
                Assert.AreEqual(directory.Uri, directoryFromShareListingFiles.Uri);

                // List files from directory.
                IListFileItem fileFromDirectoryListingFiles = directory.ListFilesAndDirectories().First();
                Assert.AreEqual(originalFile.Uri, fileFromDirectoryListingFiles.Uri);

                // Check Name
                Assert.AreEqual <string>(fileName, originalFile.Name);

                // Absolute URI access from CloudFile
                CloudFile fileInfo = new CloudFile(originalFile.Uri, service.Credentials);
                fileInfo.FetchAttributes();

                // Access from CloudFileDirectory
                CloudFileDirectory cloudFileDirectory         = share.GetRootDirectoryReference().GetDirectoryReference(directoryName);
                CloudFile          fileFromCloudFileDirectory = cloudFileDirectory.GetFileReference(fileName);
                Assert.AreEqual(fileInfo.Uri, fileFromCloudFileDirectory.Uri);
            }
            finally
            {
                share.Delete();
            }
        }
示例#16
0
        public async Task CloudFileClientMaximumExecutionTimeoutAsync()
        {
            CloudFileClient    fileClient    = GenerateCloudFileClient();
            CloudFileShare     share         = fileClient.GetShareReference(Guid.NewGuid().ToString("N"));
            CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();

            byte[] buffer = FileTestBase.GetRandomBuffer(80 * 1024 * 1024);

            try
            {
                await share.CreateAsync();

                fileClient.DefaultRequestOptions.MaximumExecutionTime = TimeSpan.FromSeconds(5);

                CloudFile file = rootDirectory.GetFileReference("file");
                file.StreamWriteSizeInBytes = 1 * 1024 * 1024;
                using (MemoryStream ms = new MemoryStream(buffer))
                {
                    try
                    {
                        await file.UploadFromStreamAsync(ms);

                        Assert.Fail();
                    }
                    catch (TimeoutException ex)
                    {
                        Assert.IsInstanceOfType(ex, typeof(TimeoutException));
                    }
                    catch (StorageException ex)
                    {
                        Assert.IsInstanceOfType(ex.InnerException, typeof(TimeoutException));
                    }
                }
            }
            finally
            {
                fileClient.DefaultRequestOptions.MaximumExecutionTime = null;
                share.DeleteIfExistsAsync().Wait();
            }
        }
示例#17
0
        private async Task <bool> CloudFileDirectorySetupAsync(CloudFileShare share)
        {
            try
            {
                CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();
                for (int i = 1; i < 3; i++)
                {
                    CloudFileDirectory topDirectory = rootDirectory.GetDirectoryReference("TopDir" + i);
                    await topDirectory.CreateAsync();

                    for (int j = 1; j < 3; j++)
                    {
                        CloudFileDirectory midDirectory = topDirectory.GetDirectoryReference("MidDir" + j);
                        await midDirectory.CreateAsync();

                        for (int k = 1; k < 3; k++)
                        {
                            CloudFileDirectory endDirectory = midDirectory.GetDirectoryReference("EndDir" + k);
                            await endDirectory.CreateAsync();

                            CloudFile file1 = endDirectory.GetFileReference("EndFile" + k);
                            await file1.CreateAsync(0);
                        }
                    }

                    CloudFile file2 = topDirectory.GetFileReference("File" + i);
                    await file2.CreateAsync(0);
                }

                return(true);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#18
0
        private bool CloudFileDirectorySetup(CloudFileShare share)
        {
            try
            {
                CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();
                for (int i = 1; i < 3; i++)
                {
                    CloudFileDirectory topDirectory = rootDirectory.GetDirectoryReference("TopDir" + i);
                    topDirectory.Create();

                    for (int j = 1; j < 3; j++)
                    {
                        CloudFileDirectory midDirectory = topDirectory.GetDirectoryReference("MidDir" + j);
                        midDirectory.Create();

                        for (int k = 1; k < 3; k++)
                        {
                            CloudFileDirectory endDirectory = midDirectory.GetDirectoryReference("EndDir" + k);
                            endDirectory.Create();

                            CloudFile file1 = endDirectory.GetFileReference("EndFile" + k);
                            file1.Create(0);
                        }
                    }

                    CloudFile file2 = topDirectory.GetFileReference("File" + i);
                    file2.Create(0);
                }

                return(true);
            }
            catch (StorageException e)
            {
                throw e;
            }
        }
示例#19
0
        public void CloudFileDirectoryDelimitersInARow()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            CloudFile file = share.GetRootDirectoryReference().GetFileReference(NavigationHelper.Slash + NavigationHelper.Slash + NavigationHelper.Slash + "File1");

            ////Traverse from leaf to root
            CloudFileDirectory directory1 = file.Parent;

            Assert.AreEqual(directory1.Name, NavigationHelper.Slash + NavigationHelper.Slash + NavigationHelper.Slash);

            CloudFileDirectory directory2 = directory1.Parent;

            Assert.AreEqual(directory2.Name, NavigationHelper.Slash + NavigationHelper.Slash);

            CloudFileDirectory directory3 = directory2.Parent;

            Assert.AreEqual(directory3.Name, NavigationHelper.Slash);

            ////Traverse from root to leaf
            CloudFileDirectory directory4 = share.GetRootDirectoryReference().GetDirectoryReference(NavigationHelper.Slash);
            CloudFileDirectory directory5 = directory4.GetDirectoryReference(NavigationHelper.Slash);

            Assert.AreEqual(directory5.Name, NavigationHelper.Slash + NavigationHelper.Slash);

            CloudFileDirectory directory6 = directory5.GetDirectoryReference(NavigationHelper.Slash);

            Assert.AreEqual(directory6.Name, NavigationHelper.Slash + NavigationHelper.Slash + NavigationHelper.Slash);

            CloudFile file2 = directory6.GetFileReference("File1");

            Assert.AreEqual(file2.Name, NavigationHelper.Slash + NavigationHelper.Slash + NavigationHelper.Slash + "File1");
            Assert.AreEqual(file2.Uri, file.Uri);
        }
示例#20
0
 /// <inheritdoc />
 protected override void MoveFile(Database db, string newPath)
 {
   FileInfo newFileInfo = new FileInfo(newPath);
   m_databaseDir = m_rootDir.GetDirectoryReference(db.FileInfo.Directory.Name);
   CloudFile cloudFile = m_databaseDir.GetFileReference(db.FileInfo.Name);
   CloudFile destFile = m_databaseDir.GetFileReference(newFileInfo.Name);
   destFile.StartCopy(cloudFile); // Azure provides NO rename/move functionality !!!
   while (destFile.CopyState.Status == Microsoft.WindowsAzure.Storage.Blob.CopyStatus.Pending)
     Thread.Sleep(100);
   cloudFile.Delete();
   db.FileInfo = newFileInfo;
 }
        public async Task CloudFileClientMaximumExecutionTimeoutShouldNotBeHonoredForStreamsAsync()
        {
            CloudFileClient    fileClient    = GenerateCloudFileClient();
            CloudFileShare     share         = fileClient.GetShareReference(Guid.NewGuid().ToString("N"));
            CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();

            byte[] buffer = FileTestBase.GetRandomBuffer(1024 * 1024);

            try
            {
                await share.CreateAsync();

                fileClient.DefaultRequestOptions.MaximumExecutionTime = TimeSpan.FromSeconds(30);
                CloudFile file = rootDirectory.GetFileReference("file");
                file.StreamMinimumReadSizeInBytes = 1024 * 1024;

                using (var fileStream = await file.OpenWriteAsync(8 * 1024 * 1024))
                {
                    Stream fos = fileStream;

                    DateTime start = DateTime.Now;
                    for (int i = 0; i < 7; i++)
                    {
                        await fos.WriteAsync(buffer, 0, buffer.Length);
                    }

                    // Sleep to ensure we are over the Max execution time when we do the last write
                    int msRemaining = (int)(fileClient.DefaultRequestOptions.MaximumExecutionTime.Value - (DateTime.Now - start)).TotalMilliseconds;

                    if (msRemaining > 0)
                    {
                        await Task.Delay(msRemaining);
                    }

                    await fos.WriteAsync(buffer, 0, buffer.Length);

                    await fileStream.CommitAsync();
                }

                using (var fileStream = await file.OpenReadAsync())
                {
                    Stream fis = fileStream;

                    DateTime start = DateTime.Now;
                    int      total = 0;
                    while (total < 7 * 1024 * 1024)
                    {
                        total += await fis.ReadAsync(buffer, 0, buffer.Length);
                    }

                    // Sleep to ensure we are over the Max execution time when we do the last read
                    int msRemaining = (int)(fileClient.DefaultRequestOptions.MaximumExecutionTime.Value - (DateTime.Now - start)).TotalMilliseconds;

                    if (msRemaining > 0)
                    {
                        await Task.Delay(msRemaining);
                    }

                    while (true)
                    {
                        int count = await fis.ReadAsync(buffer, 0, buffer.Length);

                        total += count;
                        if (count == 0)
                        {
                            break;
                        }
                    }
                }
            }
            finally
            {
                fileClient.DefaultRequestOptions.MaximumExecutionTime = null;
                share.DeleteIfExistsAsync().Wait();
            }
        }