Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement if file was not found #798

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface IFilesStorage<TFile, TIdentifier>
/// <param name="fileId">File id.</param>
/// <param name="cancellationToken">CancellationToken.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.
/// The task result contains a file of type <see cref="TFile"/>.
/// The task result contains a file of type <see cref="TFile"/> or null if it was not found.
/// </returns>
Task<TFile> GetByIdAsync(TIdentifier fileId, CancellationToken cancellationToken = default);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public async Task<Result<ImageDto>> GetByIdAsync(string imageId)

if (externalImageModel == null)
{
logger.LogDebug("Image with id='{ImageId}' wasn't found", imageId);
return Result<ImageDto>.Failed(ImagesOperationErrorCode.ImageNotFoundError.GetOperationError());
}

Expand Down