private IResult ServeOriginal(string path, IStorageFile storageFile, IFormatInfo outputFormat) { var stream = storageFile.GetStream(); IAddToCacheResult cacheResult; if (MediaCache.TryAddToCache(path, stream, outputFormat, out cacheResult)) { return(new CopyToOutputStreamResult(cacheResult.LastModified, cacheResult.ETag, storageFile.ContentLength, stream)); } return(storageFile); }
public bool CopyTo(IStorageFile target) { var srcStream = this.GetStream(); if (srcStream == null) return false; using (srcStream) { using (var targetStream = target.GetStream(true)) { const int bufferSize = 1024 * 2; byte[] buffer = new byte[bufferSize]; int readCount = 0; while ((readCount = srcStream.Read(buffer, 0, bufferSize)) > 0) { targetStream.Write(buffer, 0, readCount); } } } return true; }
public async Task<bool> CopyToAsync(IStorageFile target) { var srcStream = this.GetStream(); if (srcStream == null) return false; using (srcStream) { using (var targetStream = target.GetStream(true)) { const int bufferSize = 1024 * 2; byte[] buffer = new byte[bufferSize]; int readCount = 0; while ((readCount =await srcStream.ReadAsync(buffer, 0, bufferSize)) > 0) { await targetStream.WriteAsync(buffer, 0, readCount); } } } return true; }
private IResult ServeOriginal( string path, IStorageFile storageFile, IFormatInfo outputFormat ) { var stream = storageFile.GetStream(); IAddToCacheResult cacheResult; if ( MediaCache.TryAddToCache( path, stream, outputFormat, out cacheResult ) ) { return new CopyToOutputStreamResult( cacheResult.LastModified, cacheResult.ETag, storageFile.ContentLength, stream ); } return storageFile; }