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.
54 lines
1.6 KiB
54 lines
1.6 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Infrastructure.Assets;
|
|
|
|
namespace Squidex.Domain.Apps.Entities.Backup
|
|
{
|
|
public sealed class DefaultBackupArchiveStore : IBackupArchiveStore
|
|
{
|
|
private readonly IAssetStore assetStore;
|
|
|
|
public DefaultBackupArchiveStore(IAssetStore assetStore)
|
|
{
|
|
Guard.NotNull(assetStore, nameof(assetStore));
|
|
|
|
this.assetStore = assetStore;
|
|
}
|
|
|
|
public Task DownloadAsync(Guid backupId, Stream stream, CancellationToken ct = default)
|
|
{
|
|
var fileName = GetFileName(backupId);
|
|
|
|
return assetStore.DownloadAsync(fileName, stream, ct);
|
|
}
|
|
|
|
public Task UploadAsync(Guid backupId, Stream stream, CancellationToken ct = default)
|
|
{
|
|
var fileName = GetFileName(backupId);
|
|
|
|
return assetStore.UploadAsync(fileName, stream, true, ct);
|
|
}
|
|
|
|
public Task DeleteAsync(Guid backupId)
|
|
{
|
|
var fileName = GetFileName(backupId);
|
|
|
|
return assetStore.DeleteAsync(fileName);
|
|
}
|
|
|
|
private string GetFileName(Guid backupId)
|
|
{
|
|
return $"{backupId}_0";
|
|
}
|
|
}
|
|
}
|
|
|