コード例 #1
0
 public void TestUploadResumeAndDisableTransferLogging()
 {
     try
     {
         _adlsClient.BulkUpload(LocalPathUpload2, RemotePathUpload2, 10, IfExists.Overwrite, true, null, false, true, true, default(CancellationToken));
     }
     catch (ArgumentException ex)
     {
         Assert.IsTrue(ex.Message.Contains("resume and disablelogging both cannot be true"));
     }
 }
コード例 #2
0
        /// <summary>
        /// Copies the specified file to the remote location.
        /// </summary>
        /// <exception cref="IOException">If copy process encounters any exception</exception>
        public void CopyFromLocal(string localFileName, Uri remoteFileUri)
        {
            TransferStatus status;

            try
            {
                status = status = _adlsClient.BulkUpload(localFileName, remoteFileUri.AbsolutePath);
            }
            catch (Exception ex)
            {
                throw new IOException($"Error in bulk upload from {localFileName} to {remoteFileUri}", ex);
            }
            if (status.EntriesFailed.Count != 0)
            {
                throw new IOException($"{status.EntriesFailed.Count} entries did not get transferred correctly");
            }
        }
コード例 #3
0
        // Bulk upload and download
        private static void RunFileTransfer(AdlsClient client)
        {
            Directory.CreateDirectory(localFileTransferPath);
            var fileName = localFileTransferPath + @"\testUploadFile.txt";

            Console.WriteLine("Creating the test file to upload:");
            using (var stream = new StreamWriter(new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite)))
            {
                stream.WriteLine("Hello I am the first line of upload.");
                stream.WriteLine("Hello I am the second line of upload.");
            }
            var destFile = remoteFileTransferPath + "/testremoteUploadFile.txt";

            Console.WriteLine("Upload of the file:");
            client.BulkUpload(fileName, destFile, 1); // Source and destination could also be directories
            using (var readStream = new StreamReader(client.GetReadStream(destFile)))
            {
                string line;
                while ((line = readStream.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                }
            }
            var localDestFile = localFileTransferPath + @"\testlocalDownloadFile.txt";

            Console.WriteLine("Download of the uploaded file:");
            client.BulkDownload(destFile, localDestFile, 1); // Source and destination could also be directories
            using (var stream = new StreamReader(File.OpenRead(localDestFile)))
            {
                string line;
                while ((line = stream.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                }
            }
            Directory.Delete(localFileTransferPath, true);
            client.DeleteRecursive(remoteFileTransferPath);
        }
コード例 #4
0
        /// <summary>
        /// Copies the specified file to the remote location.
        /// </summary>
        /// <exception cref="IOException">If copy process encounters any exception</exception>
        public void CopyFromLocal(string localFileName, Uri remoteFileUri)
        {
            TransferStatus status;

            try
            {
                status = _adlsClient.BulkUpload(localFileName, remoteFileUri.AbsolutePath);
            }
            catch (Exception ex)
            {
                throw new IOException($"Error in bulk upload from {localFileName} to {remoteFileUri}", ex);
            }
            if (status.EntriesFailed.Count != 0)
            {
                var failedEntriesBuilder = new StringBuilder();
                for (int i = 0; i < status.EntriesFailed.Count && i < 50; i++)
                {
                    var entry = status.EntriesFailed[i];
                    failedEntriesBuilder.Append($"Entry {entry.EntryName} failed with error message {entry.Errors}. ");
                }
                throw new IOException($"{status.EntriesFailed.Count} entries failed to upload. {failedEntriesBuilder.ToString()}");
            }
        }