title: File Transfer using gRPC ++
body: <p>My objective is to chunk a file and then use a streaming connection to send the file to a server using gRPC++. Is there anything wrong in my code? The RPC call for file upload does not seem to be successful.</p>
  
  <p>My proto file has a single object "bytes"</p>
  
  <pre><code>message FileContent {
  
    bytes content = 1;
  
  }
  </code></pre>
  
  <p>Client Code</p>
  
  <pre><code>char *buffer = new char[2048];
  // Open a stream-based connection with the gRPC server
  
  std::unique_ptr&lt;ClientWriter&lt;FileContent&gt; &gt; writer(this-&gt;service_stub-&gt;Store(&amp;context, &amp;fileack));
  // send the file name to the server
  
  filecontent.set_content(filename);
  std::cout &lt;&lt; "Client: RPC call with File Name:" &lt;&lt; filecontent.content() &lt;&lt; endl;
  writer-&gt;Write(filecontent);
  
  // Get a file handle for the file we want to upload and the file length 
  fileStream.open(filename, ios::binary);
  while (!fileStream.eof())
  {
       std::this_thread::sleep_for(std::chrono::milliseconds(100));
       filecontent.clear_content();
       fileStream.read(buffer,2048);
       filecontent.set_content(std::string(buffer, 2048));
       writer-&gt;Write(filecontent);
  }
  </code></pre>
  
  <p>Server Code</p>
  
  <pre><code>   Status Store(ServerContext* context, ServerReader&lt;FileContent&gt;* reader, FileAck* fileack) override 
  {
           FileContent filecontent;
           ofstream fileStream;
           std::string serverfilepath;
           if (fileStream.is_open())
           {
               std::cout &lt;&lt; "Reading Data";
               while (reader-&gt;Read(&amp;filecontent))
               {
                   fileStream &lt;&lt; filecontent.mutable_content();
               }
  
                 fileStream.close();
  
           }
  
           else
           {
              reader-&gt;Read(&amp;filecontent);
              fileStream.open(serverfilepath, ios::binary);
           }
  
           return Status::OK;
          }
  </code></pre>
  
  <p>The 1st RPC call for sending the file name works, but subsequent RPC calls </p>
  
  <p>are not successful. I don't see the server receiving any data. Does my code look OK?</p>