Exemplo n.º 1
0
        private async Task DownloadFileAsync(string path, ImportedFile file)
        {
            using (var fs = File.Create(path))
            {
                using (var responseStream = await _ftpLoader.LoadFileFromFtpAsync(file))
                {
                    await responseStream.CopyToAsync(fs);
                }

                await fs.FlushAsync();
            }
        }
Exemplo n.º 2
0
        public async Task SaveFileAsync(ImportedFile file)
        {
            using (var responseStream = await _ftpLoader.LoadFileFromFtpAsync(file))
            {
                CloudStorageAccount storageAccount    = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureStorageConnectionString"]);
                CloudBlobClient     blobServiceClient = storageAccount.CreateCloudBlobClient();

                CloudBlobContainer containerClient = blobServiceClient.GetContainerReference(FolderName);
                await containerClient.CreateIfNotExistsAsync();

                var blockBlob = containerClient.GetBlockBlobReference(file.OriginalFileName);
                blockBlob.Properties.ContentType = "text/xml";

                await blockBlob.UploadFromStreamAsync(responseStream);
            }
        }