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

FIX: Download file doesn't work if blob member is not specified. #2427

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions backend/Origam.Server/Controller/BlobController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

using System;
using System.ComponentModel.DataAnnotations;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Security.Principal;
Expand All @@ -34,7 +33,6 @@
using Microsoft.Net.Http.Headers;
using Origam.DA;
using Origam.Schema;
using Origam.Server;
using Origam.Workbench.Services;
using ImageMagick;
using Origam.Server.Model.Blob;
Expand All @@ -47,11 +45,11 @@ namespace Origam.Server.Controller
public class BlobController : AbstractController
{
private readonly IStringLocalizer<SharedResources> localizer;
private readonly CoreHttpTools httpTools = new CoreHttpTools();
private readonly CoreHttpTools httpTools = new();
public BlobController(
SessionObjects sessionObjects,
IStringLocalizer<SharedResources> localizer,
ILogger<AbstractController> log) : base(log, sessionObjects)
ILogger<BlobController> log) : base(log, sessionObjects)
{
this.localizer = localizer;
}
Expand Down Expand Up @@ -93,12 +91,12 @@ public IActionResult Get(Guid token)
}
Stream resultStream;
MemoryStream memoryStream;
var processBlobField
= string.IsNullOrEmpty(blobDownloadRequest.BlobMember)
var blobMemberAvailable
= !string.IsNullOrEmpty(blobDownloadRequest.BlobMember)
&& (blobDownloadRequest.Row[
blobDownloadRequest.BlobMember] != DBNull.Value);
if((blobDownloadRequest.BlobLookupId != Guid.Empty)
&& !processBlobField)
&& !blobMemberAvailable)
{
var lookupService = ServiceManager.Services
.GetService<IDataLookupService>();
Expand Down Expand Up @@ -132,7 +130,7 @@ var processBlobField
}
else
{
if(blobDownloadRequest.Row[blobDownloadRequest.BlobMember]
if(blobDownloadRequest.Row[blobDownloadRequest.BlobMember!]
== DBNull.Value)
{
return BadRequest(localizer["ErrorBlobRecordEmpty"]
Expand Down