public async Task <IActionResult> OnPost() { using var ms1 = new MemoryStream(); await PhotoFile.CopyToAsync(ms1); ms1.Position = 0; var model = new Application.Posts.Models.PostAddModel { Body = this.Body, UserId = "" }; var postId = await _postService.Create(model); var userId = User.GetUserId(); #region Upload to Vega var channel = new Grpc.Core.Channel("localhost:5005", SslCredentials.Insecure); var client = new Servers.Vega.FileService.FileServiceClient(channel); var result2 = client.UploadFile(new UploadRequest { Content = ByteString.CopyFrom(ms1.ToArray()), ContentType = PhotoFile.ContentType, Name = PhotoFile.FileName, PostId = postId, UserId = User.GetUserId() }); #endregion return(RedirectToPage("/index")); }
public async Task <IActionResult> OnPost() { using var ms1 = new MemoryStream(); await PhotoFile.CopyToAsync(ms1); ms1.Position = 0; var model = new Application.Posts.Models.PostAddModel { Body = this.Body, Content = ms1.ToArray(), MimeType = PhotoFile.ContentType, UserId = "" }; await _postService.Create(model); return(RedirectToPage("/index")); }