Helpers/StorageHelper.cs
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