mirror of https://github.com/abpframework/abp.git
9 changed files with 78 additions and 29 deletions
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Content; |
||||
|
|
||||
|
namespace Volo.CmsKit.MediaDescriptors |
||||
|
{ |
||||
|
public interface IMediaDescriptorAppService : IApplicationService |
||||
|
{ |
||||
|
Task<RemoteStreamContent> DownloadAsync(Guid id); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.BlobStoring; |
||||
|
using Volo.Abp.Content; |
||||
|
using Volo.Abp.GlobalFeatures; |
||||
|
using Volo.CmsKit.GlobalFeatures; |
||||
|
|
||||
|
namespace Volo.CmsKit.MediaDescriptors |
||||
|
{ |
||||
|
[RequiresGlobalFeature(typeof(MediaFeature))] |
||||
|
public class MediaDescriptorAppService : CmsKitAppServiceBase, IMediaDescriptorAppService |
||||
|
{ |
||||
|
protected readonly IMediaDescriptorRepository MediaDescriptorRepository; |
||||
|
protected readonly IBlobContainer<MediaContainer> MediaContainer; |
||||
|
|
||||
|
public MediaDescriptorAppService(IMediaDescriptorRepository mediaDescriptorRepository, IBlobContainer<MediaContainer> mediaContainer) |
||||
|
{ |
||||
|
MediaDescriptorRepository = mediaDescriptorRepository; |
||||
|
MediaContainer = mediaContainer; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<RemoteStreamContent> DownloadAsync(Guid id) |
||||
|
{ |
||||
|
var entity = await MediaDescriptorRepository.GetAsync(id); |
||||
|
var stream = await MediaContainer.GetAsync(id.ToString()); |
||||
|
|
||||
|
return new RemoteStreamContent(stream) |
||||
|
{ |
||||
|
ContentType = entity.MimeType |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,7 +1,7 @@ |
|||||
using Volo.Abp.AspNetCore.Mvc; |
using Volo.Abp.AspNetCore.Mvc; |
||||
using Volo.CmsKit.Localization; |
using Volo.CmsKit.Localization; |
||||
|
|
||||
namespace Volo.CmsKit.Controllers |
namespace Volo.CmsKit |
||||
{ |
{ |
||||
public abstract class CmsKitControllerBase : AbpController |
public abstract class CmsKitControllerBase : AbpController |
||||
{ |
{ |
||||
@ -0,0 +1,31 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Content; |
||||
|
using Volo.Abp.GlobalFeatures; |
||||
|
using Volo.CmsKit.GlobalFeatures; |
||||
|
|
||||
|
namespace Volo.CmsKit.MediaDescriptors |
||||
|
{ |
||||
|
[RequiresGlobalFeature(typeof(MediaFeature))] |
||||
|
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] |
||||
|
[Area("cms-kit")] |
||||
|
[Route("api/cms-kit/media")] |
||||
|
public class MediaDescriptorController : CmsKitControllerBase, IMediaDescriptorAppService |
||||
|
{ |
||||
|
protected readonly IMediaDescriptorAppService MediaDescriptorAppService; |
||||
|
|
||||
|
public MediaDescriptorController(IMediaDescriptorAppService mediaDescriptorAppService) |
||||
|
{ |
||||
|
MediaDescriptorAppService = mediaDescriptorAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("{id}")] |
||||
|
public virtual Task<RemoteStreamContent> DownloadAsync(Guid id) |
||||
|
{ |
||||
|
return MediaDescriptorAppService.DownloadAsync(id); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue