using (var stream = await this.Request.Content.ReadAsStreamAsync()) { var database = this.imageManager.GetDatabase(); // get database object var gridFsInfo = database.GridFS.Upload(stream, "FileName"); objectId = gridFsInfo.Id.ToString(); stream.Close(); } return this.Ok(objectId);
[HttpGet] [Route("~/GetImageFromServer/{objectId}")] public HttpResponseMessage GetImageFromMongo(string objectId) { var stream = this.GetImage(objectId); HttpResponseMessage response = new HttpResponseMessage(); response.Content = stream; response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); return response; } private StreamContent GetImage(string objectId) { var database = this.imageManager.GetDatabase(); var file = database.GridFS.FindOneById(new ObjectId(objectId)); var stream = file.OpenRead(); var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); return new StreamContent(stream); }
<div class="thumb-hov thumbnail-item" [ngStyle]="{'background-image': 'url(' + ImageURL+''+wb.ImageId+ ')'}">
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)