Skip to content

Commit

Permalink
Merge pull request #51 from JadynWong/jadyn/AddRemoteStreamContent
Browse files Browse the repository at this point in the history
Support `RemoteStreamContent`
  • Loading branch information
gdlcf88 committed Dec 27, 2021
2 parents a6a74b4 + af772ba commit 905a1ee
Show file tree
Hide file tree
Showing 30 changed files with 775 additions and 127 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using Volo.Abp.ObjectExtending;

namespace EasyAbp.FileManagement.Files.Dtos
{
public abstract class CreateFileBase : ExtensibleObject
{
[Required]
public string FileContainerName { get; set; }

public Guid? ParentId { get; set; }

public Guid? OwnerUserId { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
base.Validate(validationContext);

if (FileContainerName.IsNullOrWhiteSpace())
{
yield return new ValidationResult("FileContainerName should not be empty!",
new[] { nameof(FileContainerName) });
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
namespace EasyAbp.FileManagement.Files.Dtos
{
[Serializable]
public class CreateFileInput : ExtensibleObject
public class CreateFileInput : CreateFileBase
{
[Required]
public string FileContainerName { get; set; }

[Required]
public string FileName { get; set; }

public string MimeType { get; set; }

public FileType FileType { get; set; }

public Guid? ParentId { get; set; }

public Guid? OwnerUserId { get; set; }

public byte[] Content { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
Expand All @@ -34,12 +27,6 @@ public override IEnumerable<ValidationResult> Validate(ValidationContext validat
new[] {nameof(FileName)});
}

if (FileContainerName.IsNullOrWhiteSpace())
{
yield return new ValidationResult("FileContainerName should not be empty!",
new[] {nameof(FileContainerName)});
}

if (!Enum.IsDefined(typeof(FileType), FileType))
{
yield return new ValidationResult("FileType is invalid!",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Content;
using Volo.Abp.ObjectExtending;

namespace EasyAbp.FileManagement.Files.Dtos
{
[Serializable]
public class CreateFileWithStreamInput : CreateFileBase
{
public IRemoteStreamContent Content { get; set; }

public bool GenerateUniqueFileName { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
base.Validate(validationContext);

if (Content == null)
{
yield return new ValidationResult("Content should not be empty!",
new[] { nameof(Content) });
}
else if (Content.FileName.IsNullOrWhiteSpace())
{
yield return new ValidationResult("Content.FileName should not be empty!",
new[] { nameof(Content.FileName) });
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using Volo.Abp.Content;

namespace EasyAbp.FileManagement.Files.Dtos
{
public class CreateManyFileWithStreamInput : CreateFileBase
{
public List<IRemoteStreamContent> FileContents { get; set; } = new();

public bool GenerateUniqueFileName { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
base.Validate(validationContext);

if (FileContents.IsNullOrEmpty())
{
yield return new ValidationResult("FileContents should not be null or empty!",
new[] { nameof(FileContents) });
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp.ObjectExtending;

namespace EasyAbp.FileManagement.Files.Dtos
{
public class UpdateFileBase: ExtensibleObject
{
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.ObjectExtending;

namespace EasyAbp.FileManagement.Files.Dtos
{
[Serializable]
public class UpdateFileInput : ExtensibleObject
public class UpdateFileInput : UpdateFileBase
{
[Required]
public string FileName { get; set; }

public string MimeType { get; set; }

public byte[] Content { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
base.Validate(validationContext);

if (FileName.IsNullOrWhiteSpace())
{
yield return new ValidationResult("FileName should not be empty!",
new[] {nameof(FileName)});
new[] { nameof(FileName) });
}

FileName = FileName.Trim();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Content;

namespace EasyAbp.FileManagement.Files.Dtos
{
public class UpdateFileWithStreamInput : UpdateFileBase
{
public IRemoteStreamContent Content { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Content == null)
{
yield return new ValidationResult("Content should not be empty!",
new[] { nameof(Content) });
}
else if (Content.FileName.IsNullOrWhiteSpace())
{
yield return new ValidationResult("Content.FileName should not be empty!",
new[] { nameof(Content.FileName) });
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using EasyAbp.FileManagement.Files.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Content;

namespace EasyAbp.FileManagement.Files
{
Expand All @@ -15,10 +16,16 @@ public interface IFileAppService :
{
Task<CreateFileOutput> CreateAsync(CreateFileInput input);

Task<CreateFileOutput> CreateWithStreamAsync(CreateFileWithStreamInput input);

Task<CreateManyFileOutput> CreateManyAsync(CreateManyFileInput input);

Task<CreateManyFileOutput> CreateManyWithStreamAsync(CreateManyFileWithStreamInput input);

Task<FileInfoDto> UpdateAsync(Guid id, UpdateFileInput input);

Task<FileInfoDto> UpdateWithStreamAsync(Guid id, UpdateFileWithStreamInput input);

Task<FileInfoDto> MoveAsync(Guid id, MoveFileInput input);

Task DeleteAsync(Guid id);
Expand All @@ -29,6 +36,8 @@ public interface IFileAppService :

Task<FileDownloadOutput> DownloadAsync(Guid id, string token);

Task<IRemoteStreamContent> DownloadWithStreamAsync(Guid id, string token);

Task<PublicFileContainerConfiguration> GetConfigurationAsync(string fileContainerName, Guid? ownerUserId);
}
}

0 comments on commit 905a1ee

Please sign in to comment.