Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Last active January 9, 2021 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/15dd038f3944adf1c06e8562c50afe32 to your computer and use it in GitHub Desktop.
Save icebeam7/15dd038f3944adf1c06e8562c50afe32 to your computer and use it in GitHub Desktop.
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