public async Task SendFile(String filePath, String fileName) { if (blobContainer == null) { return; } try { String fullFile = filePath + fileName; messageContainer.AddInformationMessage("Uploading file..."); CloudBlockBlob blobBlock = blobContainer.GetBlockBlobReference(fileName); await blobBlock.UploadFromFileAsync(fullFile); messageContainer.AddInformationMessage("File uploaded..."); } catch (Exception e) { messageContainer.AddErrorMessage("An error occurred. Details are below", e.ToString()); } }
public BlobStorage(String connectionString = null, SystemMessageContainer container = null) { if (connectionString == null) { throw new NullReferenceException("Please provide a connection string for creating blob storage on Azure"); } messageContainer = (container == null ? new SystemMessageContainer() : container); if (CloudStorageAccount.TryParse(connectionString, out storageAccount)) { messageContainer.AddInformationMessage("Successfully connected to storage account"); } else //Failure - alert user in a friendly manner { messageContainer.AddErrorMessage("An error occurred in connecting to the storage account", "Attempted to use connection string: " + connectionString); } }