private static async Task AddImageAsync(UserServiceClient client) { var md = new Metadata(); md.Add("UserId", "1"); FileStream fs = File.OpenRead("Images/Test.jpg"); using (var call = client.AddImage(md)) { var stream = call.RequestStream; while (true) { byte[] buffer = new byte[64 * 1024]; int numRead = await fs.ReadAsync(buffer, 0, buffer.Length); if (numRead == 0) { break; } if (numRead < buffer.Length) { Array.Resize(ref buffer, numRead); } await stream.WriteAsync(new AddImageRequest() { Data = ByteString.CopyFrom(buffer) }); } await stream.CompleteAsync(); var res = await call.ResponseAsync; System.Console.WriteLine(res.IsOk); } }