Ejemplo n.º 1
0
        public void Remove(StorageFileId storageFileId)
        {
            var blob    = _blobContainer.Value;
            var blobRef = GetBlobRef(storageFileId, blob);

            if (!blobRef.Exists())
            {
                return;
            }

            blobRef.Delete();
        }
Ejemplo n.º 2
0
        public StorageData Get(StorageFileId storageFileId)
        {
            using var memorySteam = new MemoryStream();

            var blob = _blobContainer.Value;

            var blobRef = GetBlobRef(storageFileId, blob);

            if (!blobRef.Exists())
            {
                throw new InvalidOperationException($"Tried to open non existent blob '{GetBlobName(storageFileId)}'");
            }

            blobRef.DownloadToStream(memorySteam);

            var asDataArray = memorySteam.ToArray();

            return(new StorageData(storageFileId, asDataArray));
        }
Ejemplo n.º 3
0
 private static string GetBlobName(StorageFileId storageFileId)
 {
     return($"{storageFileId.Group}_{storageFileId.Id}.{storageFileId.Extension}");
 }
Ejemplo n.º 4
0
 private static CloudBlockBlob GetBlobRef(StorageFileId storageFileId, CloudBlobContainer blob)
 {
     return(blob.GetBlockBlobReference(GetBlobName(storageFileId)));
 }