public async Task DeleteAsync(string clientId, string key)
        {
            var semaphore = new SemaphoreSlim(1, 1);

            key = await MakeBlobKey(clientId, key);

            semaphore = _locks.GetOrAdd(key, semaphore);

            await semaphore.WaitAsync();

            try
            {
                var keyExists = await _storage.HasBlobAsync(BlobContainer, key);

                if (keyExists)
                {
                    await _storage.DelBlobAsync(
                        BlobContainer,
                        key);
                }
                else
                {
                    throw new KeyNotFoundException();
                }
            }
            finally
            {
                semaphore.Release();
            }
        }
        public async Task RemoveAsync(string id, FileType type)
        {
            var key = $"{id}.{GetExtention(type)}";

            if (await _blobStorage.HasBlobAsync(ContainerName, key))
            {
                await _blobStorage.DelBlobAsync(ContainerName, key);
            }
        }
Beispiel #3
0
        public async Task DeleteContentAsync(string messageId)
        {
            var blobExists = await _blobStorage.HasBlobAsync(ContainerName, messageId);

            if (blobExists)
            {
                await _blobStorage.DelBlobAsync(ContainerName, messageId);
            }
        }
        public async Task DeleteAsync(string id)
        {
            var hasBlob = await _storage.HasBlobAsync(ContainerName, id);

            if (hasBlob)
            {
                await _storage.DelBlobAsync(ContainerName, id);
            }
        }
Beispiel #5
0
        public async Task TestClean()
        {
            var items = (await _testBlob.GetListOfBlobKeysAsync(BlobContainer)).ToArray();

            foreach (var item in items)
            {
                await _testBlob.DelBlobAsync(BlobContainer, item);
            }
        }
        public async Task AddOrReplaceTransaction(Guid operationId, string hash, TransactionBlobType type, string transactionHex)
        {
            var key = GenerateKey(operationId, hash, type);

            if (await _blobStorage.HasBlobAsync(BlobContainer, key))
            {
                await _blobStorage.DelBlobAsync(BlobContainer, key);
            }
            await _blobStorage.SaveBlobAsync(BlobContainer, key, Encoding.UTF8.GetBytes(transactionHex));
        }
 public async Task DelBlobAsync(string file = null)
 {
     try
     {
         await _blobStorage.DelBlobAsync(_container, file);
     }
     catch (Exception)
     {
     }
 }
 public async Task DelBlobAsync(string file = null)
 {
     //var fileName = GetFileName(file);
     try
     {
         await _blobStorage.DelBlobAsync(_container, file);
     }
     catch (Exception ex)
     {
         return;
     }
 }
Beispiel #9
0
        public async Task DeleteAsync(string name)
        {
            if (await _blobStorage.HasBlobAsync(_imageResourceContainer, name))
            {
                await _blobStorage.DelBlobAsync(_imageResourceContainer, name);
            }

            var image = _cache.FirstOrDefault(item => item.Name == name);

            if (image != null)
            {
                _cache.Remove(image);
            }
        }
        public async Task DeleteContentAsync(EncryptedFile fileInfo)
        {
            if (fileInfo == null)
            {
                return;
            }

            var blobParts     = fileInfo.BlobName.Split(ContainerNameSeparator);
            var containerName = blobParts[0];

            var blobKey = fileInfo.FileId.ToString();

            var blobExists = await _blobStorage.HasBlobAsync(containerName, blobKey);

            if (blobExists)
            {
                await _blobStorage.DelBlobAsync(containerName, blobKey);
            }
        }
Beispiel #11
0
        public static async Task DeleteThrowNotFound(this IBlobStorage storage, string container, string key)
        {
            const int notFound = 404;

            try
            {
                await storage.DelBlobAsync(container, key);
            }
            catch (StorageException exception)
            {
                if (exception.RequestInformation != null &&
                    exception.RequestInformation.HttpStatusCode == notFound &&
                    exception.RequestInformation.ExtendedErrorInformation.ErrorCode == "BlobNotFound")
                {
                    throw new KeyNotFoundException("Blob not found", exception);
                }

                throw;
            }
        }
Beispiel #12
0
 public async Task DelBlobAsync(string container, string key)
 => await WrapAsync(async() => await _impl.DelBlobAsync(container, key), container);
Beispiel #13
0
 public async Task DelBlobAsync(string container, string key)
 => await _retryService.RetryAsync(async() => await _impl.DelBlobAsync(container, key), _onModificationsRetryCount);
Beispiel #14
0
 protected async Task DeleteBlobAsync(string blobKey)
 {
     await Storage.DelBlobAsync(_container, blobKey);
 }
Beispiel #15
0
 public async Task DeleteAsync(string id)
 {
     await _storage.DelBlobAsync(ContainerName, id);
 }