예제 #1
0
        public void Remove(StorageFileId storageFileId)
        {
            var blob    = _blobContainer.Value;
            var blobRef = GetBlobRef(storageFileId, blob);

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

            blobRef.Delete();
        }
예제 #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));
        }
예제 #3
0
 private static string GetBlobName(StorageFileId storageFileId)
 {
     return($"{storageFileId.Group}_{storageFileId.Id}.{storageFileId.Extension}");
 }
예제 #4
0
 private static CloudBlockBlob GetBlobRef(StorageFileId storageFileId, CloudBlobContainer blob)
 {
     return(blob.GetBlockBlobReference(GetBlobName(storageFileId)));
 }