public async Task <ActionResult> DeleteConfirmed(int id) { using (AzureBlobManager azureBlobManager = AzureBlobManager.getInstance()) { SoundDTO sound = soundService.GetSound(id); await Task.Run(async() => await azureBlobManager.DeleteAsync(sound.FileNameUrl)); await soundService.DeleteSoundAsync(sound); } return(RedirectToAction("Index")); }
/// <summary> /// Uploads data to blob as memory stream /// </summary> /// <param name="name">Name of the file from the POST request</param> /// <param name="newName">Returned name with current date pre-pended</param> /// <param name="abm">Reference to Azure Blob Manager</param> private static void UploadToBlobViaMemStream(string name, string newName, AzureBlobManager abm, IFormFile file) { // Convert IFormFile to B64 string and upload to blob storage using (var ms = new MemoryStream()) { file.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); abm.PutBlob(abm.ContainerName, newName, fileBytes); } }
public async Task <JsonResult> Upload(HttpPostedFileBase blob, string dateStart, string duration) { using (AzureBlobManager azureBlobManager = AzureBlobManager.getInstance()) { await soundService.MakeSoundAsync(new SoundDTO() { DateStart = dateStart, Duration = duration, FileNameUrl = await azureBlobManager.SaveAsync(blob).ConfigureAwait(true), UserId = GetId(soundService.GetUsers(), MvcApplication.cookies.Value) }); } return(JsonConvert.DeserializeObject <dynamic>("Success: " + blob.FileName)); }
public FilesController(AzureBlobManager blobManager) { _blobManager = blobManager; }