Created
April 2, 2016 14:09
-
-
Save vmussak/d552948b81965d51a231ac13ac1e5b23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IActionResult Upload(IFormFile arquivo) | |
{ | |
//Cria um blob client | |
CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient(); | |
//Recupera a referencia do container documentos | |
CloudBlobContainer container = blobClient.GetContainerReference("documentos"); | |
//Caso não exista, ele cria | |
container.CreateIfNotExists(); | |
//Setar permissão de acesso para 'público' | |
container.SetPermissions( | |
new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob } | |
); | |
//Recupera a referência de um blob chamado 'cliente01' | |
CloudBlockBlob blockBlob = container.GetBlockBlobReference("cliente01.pdf"); | |
//Stream do arquivo | |
Stream streamFile = arquivo.OpenReadStream(); | |
//Cria ou substitui o blob com o conteúdo do upload | |
blockBlob.UploadFromStream(streamFile); | |
return RedirectToAction("VerArquivos"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment