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.
46 lines
1.4 KiB
46 lines
1.4 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Squidex.Assets;
|
|
using Squidex.Infrastructure;
|
|
|
|
namespace Squidex.Domain.Users
|
|
{
|
|
public sealed class DefaultUserPictureStore : IUserPictureStore
|
|
{
|
|
private readonly IAssetStore assetStore;
|
|
|
|
public DefaultUserPictureStore(IAssetStore assetStore)
|
|
{
|
|
Guard.NotNull(assetStore, nameof(assetStore));
|
|
|
|
this.assetStore = assetStore;
|
|
}
|
|
|
|
public Task UploadAsync(string userId, Stream stream, CancellationToken ct = default)
|
|
{
|
|
var fileName = GetFileName(userId);
|
|
|
|
return assetStore.UploadAsync(fileName, stream, true, ct);
|
|
}
|
|
|
|
public Task DownloadAsync(string userId, Stream stream, CancellationToken ct = default)
|
|
{
|
|
var fileName = GetFileName(userId);
|
|
|
|
return assetStore.DownloadAsync(fileName, stream, default, ct);
|
|
}
|
|
|
|
private static string GetFileName(string userId)
|
|
{
|
|
return $"{userId}_0_picture";
|
|
}
|
|
}
|
|
}
|
|
|