Пример #1
0
 public async Task <bool> Delete(string imageUrl, string imageContainer)
 {
     try
     {
         await _fileStorage.Delete(imageUrl, imageContainer);
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Пример #2
0
        public async Task <IActionResult> DeleteAsync([FromRoute] int id)
        {
            try
            {
                await _adultRepo.DeleteAdultAsync(id);

                return(Ok());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(500, e.Message));
            }

            var cena = _fileStorage.Delete(id);

            if (cena)
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Пример #3
0
        public IFile CopyToWorkingDirectory(Guid processId, string filePath)
        {
            if (!_fileStorage.Exists(filePath))
            {
                throw new FileNotFoundException($"File at path '{filePath}' not found.");
            }

            _logger.LogInfo("Waiting on file to be ready...");
            _fileStorage.WaitForFileReady(filePath, _settings.DropFileReadyTimeout);
            _logger.LogInfo("File ready.");

            var file = _fileStorage.GetFile(filePath);

            ValidateIntegrationFile(file);

            var workingFileInfo = GetWorkingFileInfo(file, processId);

            _logger.LogInfo($"Copying dropped file at '{file}' to '{workingFileInfo}'...");
            string workingFilePath = _fileStorage.CopyFile(file.FullPath, workingFileInfo.FullPath);

            _logger.LogInfo("Copying complete.");

            if (_settings.DeleteFromDropDirectory)
            {
                _logger.LogInfo($"Deleting dropped file at '{filePath}'...");
                _fileStorage.Delete(filePath);
                _logger.LogInfo($"Dropped file deleted.");
            }

            return(_fileStorage.GetFile(workingFilePath));
        }
Пример #4
0
        public async Task DeleteAsync(int id)
        {
            var documents = await _unitOfWork.DocumentRepository.GetByIdAsync(id);

            await Task.Run(() => _storageLogger.Delete(documents.Path));

            _unitOfWork.DocumentRepository.Remove(documents);
            await _unitOfWork.SaveAsync();
        }
Пример #5
0
        public void CanDeleteFile(string key)
        {
            string testDescription = $"Object can be deleted by '{key}' key";

            ExecuteCheck(testDescription, async() =>
            {
                await fileStorage.Delete(bucket, key);
            });
        }
Пример #6
0
        public async Task DeleteFileAsync(long fileId)
        {
            try
            {
                var fileEntity = await _repository.GetAsync(fileId);

                if (fileEntity != null)
                {
                    _fileStorage.Delete(fileEntity.FileName);
                    await _repository.DeleteAsync(fileId);
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Unable to delete file for fileId {fileId}: {e.Message}");
                throw;
            }
        }
Пример #7
0
 public async Task <bool> Delete(string fileName)
 {
     try
     {
         return(await fileService.Delete(Path.Combine(fileService.MyDocumentsPath, fileName)));
     }
     catch
     {
         return(false);
     }
 }
        public async Task Delete(Uri uri)
        {
            var info = metaStorage.Get(uri);

            if (!securityManager.MayDelete(info))
            {
                throw new SecurityException("No access to delete");
            }

            await fileStorage.Delete(uri);

            metaStorage.Delete(uri);
        }
Пример #9
0
        public async Task ClearUnConfirmed()
        {
            var before   = DateTime.UtcNow.AddDays(-1);
            var toDelete = await set.Where(x => x.Confirmed == false && x.Date <= before).ToArrayAsync();

            set.RemoveRange(toDelete);
            foreach (var k in toDelete.Select(x => x.Key))
            {
                await storage.Delete(k);

                ClearCache(k);
            }
            await context.SaveChangesAsync();
        }
Пример #10
0
        public async Task Delete(long tenantId, string imageId, string gallery)
        {
            var filenames = new[]
            {
                Filename(tenantId, imageId, gallery, CoverDisplay),
                Filename(tenantId, imageId, gallery, StandardDisplay),
                Filename(tenantId, imageId, gallery, ThumbnailDisplay)
            };

            foreach (var filename in filenames)
            {
                await _fileStorage.Delete(filename);

                _messageBroker.Publish(new ImageDeletedEvent(filename));
            }
        }
Пример #11
0
        protected override void DoWork()
        {
            var file    = File.ReadAllBytes("plane.jpg");
            var newName = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}.jpg";
            var url     = AsyncHelper.RunSync(() => _fileStorage.Save(file, newName, "test"));

            Console.WriteLine(url);

            var bytesFromAzure = AsyncHelper.RunSync(() => _fileStorage.ReadAsBytes(newName, "test"));

            File.WriteAllBytes(newName, bytesFromAzure);

            AsyncHelper.RunSync(() => _fileStorage.Delete(newName, "test"));

            using (var fs = new FileStream("plane.jpg", FileMode.Open))
            {
                var sName = $"{newName}-as-stream.jpg";
                var url2  = AsyncHelper.RunSync(() => _fileStorage.Save(fs, sName, "test"));
            }
        }
Пример #12
0
        private async Task CreateMediaFile(string instanceId, string dataType, string?authorId,
                                           IFormFile formFile, FileUploadDto mediaDto)
        {
            await CreateMediaFileInFileSystem(formFile, instanceId);

            using var transaction = _context.Database.BeginTransactionAsync();
            try
            {
                await CreateMediaInstanceInDatabase(instanceId, dataType, authorId, mediaDto);

                await transaction.Result.CommitAsync(CancellationToken.None);
            }
            catch
            {
                await transaction.Result.RollbackAsync(CancellationToken.None);

                _fileStorage.Delete(instanceId);
                throw;
            }
        }
Пример #13
0
        private void CleanUpArchive(string archiveDirectory, int limit)
        {
            var archiveFiles = _fileStorage.GetFiles(archiveDirectory);

            if (archiveFiles == null || archiveFiles.Count == 0)
            {
                return;
            }

            _logger.LogInfo($"Cleaning up any archive files in '{archiveDirectory}' (keeping {limit} in archive)...");

            for (int i = 0; i < archiveFiles.Count; i++)
            {
                if ((i + 1) > limit)
                {
                    string fullPath = archiveFiles[i].FullPath;
                    _fileStorage.Delete(fullPath);
                    _logger.LogInfo($"Archive '{fullPath}' deleted.");
                }
            }

            _logger.LogInfo("Archive cleanup complete.");
        }
 public void Delete(IOConnectionInfo ioc)
 {
     _baseStorage.Delete(ioc);
 }