Headless CMS and Content Managment Hub
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.
 
 
 
 
 

42 lines
1.3 KiB

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.Assets;
namespace Squidex.Domain.Users
{
public sealed class DefaultUserPictureStore : IUserPictureStore
{
private readonly IAssetStore assetStore;
public DefaultUserPictureStore(IAssetStore 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";
}
}
}