public async Task <IActionResult> DeleteFile(BlobStorageModels model) { var user = await _userManager.GetUserAsync(HttpContext.User); _blobStorageService.DeleteFile("icehockey", model.FileDelete.ID, user.UserName); return(View("Index")); }
public async Task UploadFile(string containerName, BlobStorageModels model) { // upload blob _container = _blobClient.GetContainerReference(containerName); CloudBlockBlob blockBlob = _container.GetBlockBlobReference(model.File.File.FileName); using Stream stream = model.File.File.OpenReadStream(); blockBlob.UploadFromStream(stream); // update table storage Microsoft.Azure.Cosmos.Table.CloudStorageAccount cloudStorageAccount = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.DevelopmentStorageAccount; CloudTableClient tableClient = cloudStorageAccount.CreateCloudTableClient(new TableClientConfiguration()); CloudTable table = tableClient.GetTableReference("BlobDetails"); await table.CreateIfNotExistsAsync(); FileTableEntity newFile = new FileTableEntity { PartitionKey = containerName, Owner = model.File.Owner, Url = blockBlob.Uri.AbsoluteUri, Type = model.File.Type, DataFormat = model.File.DataFormat, Date = model.File.Date, Location = model.File.Location, Author = model.File.Author }; TableOperation insert = TableOperation.InsertOrMerge(newFile); TableResult result = await table.ExecuteAsync(insert); }
public async Task <IActionResult> UploadFile(BlobStorageModels model) { var user = await _userManager.GetUserAsync(HttpContext.User); model.File.Owner = user.UserName; await _blobStorageService.UploadFile("icehockey", model); return(View("Index")); }
public IActionResult ListFiles(BlobStorageModels model) { var files = _blobStorageService.SearchFiles("icehockey", model.SearchTerm.Search); BlobStorageModels newModel = new BlobStorageModels(); newModel.ListFileTableEntity.FileTableEntitiesList = files; return(View("Index", newModel)); }