mirror of https://github.com/abpframework/abp.git
10 changed files with 185 additions and 57 deletions
@ -0,0 +1,57 @@ |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.BlobStoring |
|||
{ |
|||
public static class BlobContainerExtensions |
|||
{ |
|||
public static async Task SaveAsync( |
|||
this IBlobContainer container, |
|||
string name, |
|||
byte[] bytes, |
|||
bool overrideExisting = false, |
|||
CancellationToken cancellationToken = default |
|||
) |
|||
{ |
|||
using (var memoryStream = new MemoryStream(bytes)) |
|||
{ |
|||
await container.SaveAsync( |
|||
name, |
|||
memoryStream, |
|||
overrideExisting, |
|||
cancellationToken |
|||
); |
|||
} |
|||
} |
|||
|
|||
public static async Task<byte[]> GetAllBytesAsync( |
|||
this IBlobContainer container, |
|||
string name, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
using (var stream = await container.GetAsync(name, cancellationToken)) |
|||
{ |
|||
return await stream.GetAllBytesAsync(cancellationToken); |
|||
} |
|||
} |
|||
|
|||
public static async Task<byte[]> GetAllBytesOrNullAsync( |
|||
this IBlobContainer container, |
|||
string name, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
var stream = await container.GetOrNullAsync(name, cancellationToken); |
|||
if (stream == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
using (stream) |
|||
{ |
|||
return await stream.GetAllBytesAsync(cancellationToken); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using System; |
|||
using System.Runtime.Serialization; |
|||
|
|||
namespace Volo.Abp |
|||
{ |
|||
public class AbpShutdownException : AbpException |
|||
{ |
|||
public AbpShutdownException() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public AbpShutdownException(string message) |
|||
: base(message) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public AbpShutdownException(string message, Exception innerException) |
|||
: base(message, innerException) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public AbpShutdownException(SerializationInfo serializationInfo, StreamingContext context) |
|||
: base(serializationInfo, context) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue