public async Task<byte[]> DownloadAsBytesByNameAsync(string gfsname, MediaTypeEnum bucketName) { var bucket = new GridFSBucket(_db, new GridFSBucketOptions { BucketName = bucketName.ToString() }); return await bucket.DownloadAsBytesByNameAsync(gfsname); }
private async Task<FileContentResult> GetProfileService(string fileName) { GridFSBucketOptions bucketOptions = new GridFSBucketOptions() { BucketName = "ProfileImages" }; var fs = new GridFSBucket(KonradRequirementsDatabase, bucketOptions); var t = fs.DownloadAsBytesByNameAsync(fileName); Task.WaitAll(t); byte[] image = t.Result; return File(image, "image/jpg"); }