mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
43 lines
1.2 KiB
// ==========================================================================
|
|
// AssetUserPictureStore.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Infrastructure.Assets;
|
|
|
|
namespace Squidex.Domain.Users
|
|
{
|
|
public sealed class AssetUserPictureStore : IUserPictureStore
|
|
{
|
|
private readonly IAssetStore assetStore;
|
|
|
|
public AssetUserPictureStore(IAssetStore assetStore)
|
|
{
|
|
Guard.NotNull(assetStore, nameof(assetStore));
|
|
|
|
this.assetStore = assetStore;
|
|
}
|
|
|
|
public Task UploadAsync(string userId, Stream stream)
|
|
{
|
|
return assetStore.UploadAsync(userId, 0, "picture", stream);
|
|
}
|
|
|
|
public async Task<Stream> DownloadAsync(string userId)
|
|
{
|
|
var memoryStream = new MemoryStream();
|
|
|
|
await assetStore.DownloadAsync(userId, 0, "picture", memoryStream);
|
|
|
|
memoryStream.Position = 0;
|
|
|
|
return memoryStream;
|
|
}
|
|
}
|
|
}
|
|
|