I have asked this question in 
SO 
https://stackoverflow.com/questions/52197359/sending-back-a-file-stream-from-grpc-python-server?noredirect=1#comment91343967_52197359

But I would like to try my luck here also...

I have a service that needs to return a filestream to the calling client so 
I have created this proto file.

    service Sample {
         rpc getSomething(Request) returns (stream Response){}
    }
    
    message Request {
    
    }
    
    message Response {
    bytes data = 1;
    }

When the server receives this, it needs to read some source.txt file and 
then write it back to the client
as a byte stream.  Just would like to ask is this the proper way to do this 
in a Python GRPC server?

    fileName = "source.txt"
    with open(file_name, 'r') as content_file:
        content = content_file.read()
    response.data = content.encode()
    yield response
I cannot find any examples related to this that is written in Python.

I am a newbie GRPC/Python Coder also, I just need to implement this 
functionality so please bear with me.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/cb571f0f-170b-4962-8c5c-6cdd38a3e7ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to