Esempio n. 1
0
        public static MediaDto FromDomainObject(MediaItem media, string appId, IUrlGenerator urlGenerator)
        {
            var result = SimpleMapper.Map(media, new MediaDto());

            result.Url = urlGenerator.BuildUrl($"api/apps/{appId}/media/{media.FileName}", false);

            return(result);
        }
Esempio n. 2
0
 private async Task ResizeAsync(string appId, MediaItem media, Stream bodyStream, string fileName, ResizeOptions resizeOptions, bool overwrite, CancellationToken ct)
 {
     using (Profiler.Trace("Resize"))
     {
         using (var sourceStream = GetTempStream())
         {
             using (var destinationStream = GetTempStream())
             {
                 using (Profiler.Trace("ResizeDownload"))
                 {
                     await mediaFileStore.DownloadAsync(appId, media, sourceStream, default, ct);
Esempio n. 3
0
        private async Task ResizeAsync(string appId, MediaItem media, Stream target, string fileName, ResizeOptions resizeOptions, bool overwrite,
                                       CancellationToken ct)
        {
#pragma warning disable MA0040 // Flow the cancellation token
            using var activity = Telemetry.Activities.StartActivity("Resize");

            await using var assetOriginal = new TempAssetFile(media.FileName, media.MimeType, 0);
            await using var assetResized  = new TempAssetFile(media.FileName, media.MimeType, 0);

            using (Telemetry.Activities.StartActivity("Read"))
            {
                await using (var originalStream = assetOriginal.OpenWrite())
                {
                    await mediaFileStore.DownloadAsync(appId, media, originalStream, default, ct);
Esempio n. 4
0
        public static MediaDto FromDomainObject(MediaItem source)
        {
            var result = SimpleMapper.Map(source, new MediaDto());

            return(result);
        }
Esempio n. 5
0
 private static string CreateFileName(string appId, Media media)
 {
     return($"{appId}_{media.FileName}");
 }
Esempio n. 6
0
        public Task UploadAsync(string appId, Media media, Stream stream, CancellationToken ct)
        {
            var fileName = CreateFileName(appId, media);

            return(assetStore.UploadAsync(fileName, stream, true, ct));
        }
Esempio n. 7
0
        public Task DownloadAsync(string appId, Media media, Stream stream, BytesRange range, CancellationToken ct)
        {
            var fileName = CreateFileName(appId, media);

            return(assetStore.DownloadAsync(fileName, stream, range, ct));
        }