Helpers/StorageHelper.cs
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
using System; | |
using System.IO; | |
using System.Threading.Tasks; | |
using Azure.Storage; | |
using Azure.Storage.Blobs; | |
namespace UniversidadWebsite.Helpers | |
{ | |
public static class StorageHelper | |
{ | |
public static async Task<string> SubirArchivo(Stream contenido, string nombre, AzureStorageConfig config) | |
{ | |
var url = $"https://{config.Cuenta}.blob.core.windows.net/{config.Contenedor}/{nombre}"; | |
var uri = new Uri(url); | |
var credenciales = new StorageSharedKeyCredential(config.Cuenta, config.Llave); | |
var cliente = new BlobClient(uri, credenciales); | |
await cliente.UploadAsync(contenido); | |
return url; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment