mirror of https://github.com/Squidex/squidex.git
16 changed files with 321 additions and 153 deletions
@ -0,0 +1,43 @@ |
|||||
|
// ==========================================================================
|
||||
|
// 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.Read.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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
// ==========================================================================
|
||||
|
// IUserPictureStore.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.IO; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Squidex.Read.Users |
||||
|
{ |
||||
|
public interface IUserPictureStore |
||||
|
{ |
||||
|
Task UploadAsync(string userId, Stream stream); |
||||
|
|
||||
|
Task<Stream> DownloadAsync(string userId); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue