diff --git a/OutOfSchool/OutOfSchool.DataAccess/Repository/Files/GcpFilesStorageBase.cs b/OutOfSchool/OutOfSchool.DataAccess/Repository/Files/GcpFilesStorageBase.cs index 59d32371eb..abdac6df47 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Repository/Files/GcpFilesStorageBase.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Repository/Files/GcpFilesStorageBase.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Google; using Google.Api.Gax; using Google.Apis.Auth.OAuth2; using Google.Apis.Storage.v1.Data; @@ -60,6 +61,10 @@ await StorageClient.DownloadObjectAsync( fileStream.Position = 0; return new TFile { ContentStream = fileStream, ContentType = fileObject.ContentType }; } + catch (GoogleApiException) + { + return null; + } catch (Exception ex) { throw new FileStorageException(ex); diff --git a/OutOfSchool/OutOfSchool.DataAccess/Repository/Files/IFilesStorage.cs b/OutOfSchool/OutOfSchool.DataAccess/Repository/Files/IFilesStorage.cs index facb7a9b25..e38dc7c2b3 100644 --- a/OutOfSchool/OutOfSchool.DataAccess/Repository/Files/IFilesStorage.cs +++ b/OutOfSchool/OutOfSchool.DataAccess/Repository/Files/IFilesStorage.cs @@ -28,7 +28,7 @@ public interface IFilesStorage /// File id. /// CancellationToken. /// A representing the result of the asynchronous operation. - /// The task result contains a file of type . + /// The task result contains a file of type or null if it was not found. /// Task GetByIdAsync(TIdentifier fileId, CancellationToken cancellationToken = default); diff --git a/OutOfSchool/OutOfSchool.WebApi/Services/Images/ImageService.cs b/OutOfSchool/OutOfSchool.WebApi/Services/Images/ImageService.cs index 138aa1b530..311a85ce5d 100644 --- a/OutOfSchool/OutOfSchool.WebApi/Services/Images/ImageService.cs +++ b/OutOfSchool/OutOfSchool.WebApi/Services/Images/ImageService.cs @@ -62,6 +62,7 @@ public async Task> GetByIdAsync(string imageId) if (externalImageModel == null) { + logger.LogDebug("Image with id='{ImageId}' wasn't found", imageId); return Result.Failed(ImagesOperationErrorCode.ImageNotFoundError.GetOperationError()); }