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); }
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);
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);
public static MediaDto FromDomainObject(MediaItem source) { var result = SimpleMapper.Map(source, new MediaDto()); return(result); }
private static string CreateFileName(string appId, Media media) { return($"{appId}_{media.FileName}"); }
public Task UploadAsync(string appId, Media media, Stream stream, CancellationToken ct) { var fileName = CreateFileName(appId, media); return(assetStore.UploadAsync(fileName, stream, true, ct)); }
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)); }