Browse Source
Merge pull request #8204 from abpframework/liangshiwei/blob-database
Use sync API to download Blob
pull/8220/head
maliming
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
6 deletions
-
modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlob.cs
-
modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreDatabaseBlobRepository.cs
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using JetBrains.Annotations; |
|
|
|
using System; |
|
|
|
using Volo.Abp.Auditing; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
|
|
|
|
@ -13,6 +14,7 @@ namespace Volo.Abp.BlobStoring.Database |
|
|
|
|
|
|
|
public virtual string Name { get; protected set; } |
|
|
|
|
|
|
|
[DisableAuditing] |
|
|
|
public virtual byte[] Content { get; protected set; } |
|
|
|
|
|
|
|
public DatabaseBlob(Guid id, Guid containerId, [NotNull] string name, [NotNull] byte[] content, Guid? tenantId = null) |
|
|
|
@ -32,7 +34,7 @@ namespace Volo.Abp.BlobStoring.Database |
|
|
|
protected virtual byte[] CheckContentLength(byte[] content) |
|
|
|
{ |
|
|
|
Check.NotNull(content, nameof(content)); |
|
|
|
|
|
|
|
|
|
|
|
if (content.Length >= DatabaseBlobConsts.MaxContentLength) |
|
|
|
{ |
|
|
|
throw new AbpException($"Blob content size cannot be more than {DatabaseBlobConsts.MaxContentLength} Bytes."); |
|
|
|
@ -41,4 +43,4 @@ namespace Volo.Abp.BlobStoring.Database |
|
|
|
return content; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|
|
|
@ -20,10 +21,9 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore |
|
|
|
string name, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await (await GetDbSetAsync()) |
|
|
|
.FirstOrDefaultAsync( |
|
|
|
x => x.ContainerId == containerId && x.Name == name, |
|
|
|
GetCancellationToken(cancellationToken) |
|
|
|
return (await GetDbSetAsync()) |
|
|
|
.FirstOrDefault( |
|
|
|
x => x.ContainerId == containerId && x.Name == name |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|