Esempio n. 1
0
        private async Task <CatalogEntity> BackupToTableAsync(CatalogItem item)
        {
            StorageAccHelper storageAccHelper = new StorageAccHelper();

            storageAccHelper.TableConnectionString = configuration.GetConnectionString("TableConnection");
            return(await storageAccHelper.SaveToAzureTableAsync(item));
        }
Esempio n. 2
0
        private async Task <string> SaveImageToCloudAsync(IFormFile image)
        {
            var imageName = $"{Guid.NewGuid()}_{image.FileName}";
            var tempFile  = Path.GetTempFileName();

            using (FileStream fs = new FileStream(tempFile, FileMode.Create))
            {
                await image.CopyToAsync(fs);
            }
            var imageFile = Path.Combine(Path.GetDirectoryName(tempFile), imageName);

            System.IO.File.Move(tempFile, imageFile);
            StorageAccHelper storageAccHelper = new StorageAccHelper();

            storageAccHelper.StorageConnectionString = configuration.GetConnectionString("StorageConnection");
            var fileUri = await storageAccHelper.UploadFileToBlobAsync(imageFile, "eshopimages");

            System.IO.File.Delete(imageFile);
            return(fileUri);
        }