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.
44 lines
1.2 KiB
44 lines
1.2 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Squidex.Infrastructure.Assets
|
|
{
|
|
public sealed class AssetFile
|
|
{
|
|
private readonly Func<Stream> openAction;
|
|
|
|
public string FileName { get; }
|
|
|
|
public string MimeType { get; }
|
|
|
|
public long FileSize { get; }
|
|
|
|
[JsonConstructor]
|
|
public AssetFile(string fileName, string mimeType, long fileSize, Func<Stream> openAction)
|
|
{
|
|
Guard.NotNullOrEmpty(fileName, nameof(fileName));
|
|
Guard.NotNullOrEmpty(mimeType, nameof(mimeType));
|
|
Guard.GreaterEquals(fileSize, 0, nameof(fileSize));
|
|
|
|
FileName = fileName;
|
|
FileSize = fileSize;
|
|
|
|
MimeType = mimeType;
|
|
|
|
this.openAction = openAction;
|
|
}
|
|
|
|
public Stream OpenRead()
|
|
{
|
|
return openAction();
|
|
}
|
|
}
|
|
}
|
|
|