예제 #1
0
        public static async Task <NotFoundFileResult> Create()
        {
            var r = new NotFoundFileResult();
            var b = Encoding.UTF8.GetBytes("The file is no longer on the server. It could have been deleted as it was too old. Please try again, or if it was not long since created, please raise an issue on the project webpage.");
            await r.WriteAsync(b);

            r.Seek(0, SeekOrigin.Begin);
            return(r);
        }
예제 #2
0
        public async Task <Stream> Get(DownloadFileRequest request)
        {
            var filePath = Directory.GetFiles(outputDirectoryProvider.GetOutputDirectory(), $"{request.Id}.*").FirstOrDefault();

            if (filePath == null)
            {
                return(await NotFoundFileResult.Create());
            }
            else
            {
                var extension    = Path.GetExtension(filePath);
                var downloadName = $"{DateTime.Now:yyyyMMdd_HHmmss}{extension}";
                var result       = await DownloadFileResult.Create(downloadName, filePath);

                File.Delete(filePath);
                return(result);
            }
        }