public async Task <ActionResult> DownloadFileAsync(string fileId)
        {
            var userId = Tools.AuthenticationManager.GetUserId(User);

            #region
            DatabaseModule.Entities.File file;
            try
            {
                file = await _filesRepository.FindByIdAsync(fileId);
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(BadRequest("File not found"));
            }
            #endregion

            if (!FileFolderManager.CanAccessFile(userId, file))
            {
                return(BadRequest("User doesn't have access to file"));
            }

            #region Get file from db
            DatabaseModule.Entities.Bucket bucket;
            try
            {
                bucket = await _bucketsRepository.FindByIdAsync(file.BucketId.ToString());
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(BadRequest("Bucket not found"));
            }
            #endregion

            var serviceConfig        = bucket.BucketConfigData;
            var googleBucketUploader = new RequestHandlerGoogleBucket(serviceConfig.ConfigData, serviceConfig.SelectedBucket);
            var result = googleBucketUploader.DownloadFile(file);


            return(File(result, file.FileType, file.FileName));
        }
        public async Task <ActionResult> GetFileInfo(ObjectIdRequest fileIdRequest)
        {
            var userId = Tools.AuthenticationManager.GetUserId(User);
            var file   = await _filesRepository.FindByIdAsync(fileIdRequest.Id);

            if (!FileFolderManager.CanAccessFile(userId, file))
            {
                return(BadRequest("You don't have access to file or it doesn't exist"));
            }

            return(Ok(JsonSerializer.Serialize(
                          new FileInfoWithUser(file),
                          new JsonSerializerOptions()
            {
                Converters =
                {
                    new FileInfoWithUserSerializer()
                }
            })));
        }