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> OnGetImageAsync(int postId) { //var channel = GrpcChannel.ForAddress("http://localhost:5005"); //var client = new Servers.Vega.FileService.FileServiceClient(channel); var channel = GrpcChannel.ForAddress("https://localhost:5005"); var client = new Servers.Vega.FileService.FileServiceClient(channel); var result = await client.DownloadFileAsync(new Servers.Vega.DownloadRequest { PostId = postId }); return(File(result.Content.ToArray(), result.ContentType)); }