mirror of https://github.com/Squidex/squidex.git
29 changed files with 447 additions and 789 deletions
@ -1,25 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.Infrastructure.Commands; |
|||
|
|||
namespace Squidex.Domain.Apps.Entities.Assets |
|||
{ |
|||
public class AssetSavedResult : EntitySavedResult |
|||
{ |
|||
public long FileVersion { get; } |
|||
|
|||
public string FileHash { get; } |
|||
|
|||
public AssetSavedResult(long version, long fileVersion, string fileHash) |
|||
: base(version) |
|||
{ |
|||
FileVersion = fileVersion; |
|||
FileHash = fileHash; |
|||
} |
|||
} |
|||
} |
|||
@ -1,108 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Squidex.Domain.Apps.Entities.Assets; |
|||
using Squidex.Domain.Apps.Entities.Assets.Commands; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Squidex.Areas.Api.Controllers.Assets.Models |
|||
{ |
|||
public sealed class AssetCreatedDto |
|||
{ |
|||
/// <summary>
|
|||
/// The id of the asset.
|
|||
/// </summary>
|
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The file type.
|
|||
/// </summary>
|
|||
[Required] |
|||
public string FileType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The file name.
|
|||
/// </summary>
|
|||
[Required] |
|||
public string FileName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The slug.
|
|||
/// </summary>
|
|||
[Required] |
|||
public string Slug { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The mime type.
|
|||
/// </summary>
|
|||
[Required] |
|||
public string MimeType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The default tags.
|
|||
/// </summary>
|
|||
[Required] |
|||
public HashSet<string> Tags { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The size of the file in bytes.
|
|||
/// </summary>
|
|||
public long FileSize { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The version of the file.
|
|||
/// </summary>
|
|||
public long FileVersion { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Determines of the created file is an image.
|
|||
/// </summary>
|
|||
public bool IsImage { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The width of the image in pixels if the asset is an image.
|
|||
/// </summary>
|
|||
public int? PixelWidth { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The height of the image in pixels if the asset is an image.
|
|||
/// </summary>
|
|||
public int? PixelHeight { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Indicates if the asset has been already uploaded.
|
|||
/// </summary>
|
|||
public bool IsDuplicate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The version of the asset.
|
|||
/// </summary>
|
|||
public long Version { get; set; } |
|||
|
|||
public static AssetCreatedDto FromCommand(CreateAsset command, AssetCreatedResult result) |
|||
{ |
|||
return new AssetCreatedDto |
|||
{ |
|||
Id = result.IdOrValue, |
|||
FileName = command.File.FileName, |
|||
FileSize = command.File.FileSize, |
|||
FileType = command.File.FileName.FileType(), |
|||
FileVersion = result.FileVersion, |
|||
MimeType = command.File.MimeType, |
|||
IsImage = command.ImageInfo != null, |
|||
IsDuplicate = result.IsDuplicate, |
|||
PixelWidth = command.ImageInfo?.PixelWidth, |
|||
PixelHeight = command.ImageInfo?.PixelHeight, |
|||
Tags = result.Tags, |
|||
Version = result.Version |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
namespace Squidex.Areas.Api.Controllers.Assets.Models |
|||
{ |
|||
public sealed class AssetMetadata |
|||
{ |
|||
/// <summary>
|
|||
/// Indicates whether the asset is a duplicate.
|
|||
/// </summary>
|
|||
public string IsDuplicate { get; set; } |
|||
} |
|||
} |
|||
@ -1,74 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
using Squidex.Domain.Apps.Entities.Assets; |
|||
using Squidex.Domain.Apps.Entities.Assets.Commands; |
|||
|
|||
namespace Squidex.Areas.Api.Controllers.Assets.Models |
|||
{ |
|||
public sealed class AssetReplacedDto |
|||
{ |
|||
/// <summary>
|
|||
/// The mime type.
|
|||
/// </summary>
|
|||
[Required] |
|||
public string MimeType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The file hash.
|
|||
/// </summary>
|
|||
[Required] |
|||
public string FileHash { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The size of the file in bytes.
|
|||
/// </summary>
|
|||
public long FileSize { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The version of the file.
|
|||
/// </summary>
|
|||
public long FileVersion { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Determines of the created file is an image.
|
|||
/// </summary>
|
|||
public bool IsImage { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The width of the image in pixels if the asset is an image.
|
|||
/// </summary>
|
|||
public int? PixelWidth { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The height of the image in pixels if the asset is an image.
|
|||
/// </summary>
|
|||
public int? PixelHeight { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The version of the asset.
|
|||
/// </summary>
|
|||
public long Version { get; set; } |
|||
|
|||
public static AssetReplacedDto FromCommand(UpdateAsset command, AssetSavedResult result) |
|||
{ |
|||
var response = new AssetReplacedDto |
|||
{ |
|||
FileSize = command.File.FileSize, |
|||
FileVersion = result.FileVersion, |
|||
MimeType = command.File.MimeType, |
|||
IsImage = command.ImageInfo != null, |
|||
PixelWidth = command.ImageInfo?.PixelWidth, |
|||
PixelHeight = command.ImageInfo?.PixelHeight, |
|||
Version = result.Version |
|||
}; |
|||
|
|||
return response; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue