Last active
September 9, 2022 15:48
-
-
Save wfng92/76f166dcc64299937d0efabbaa6acb37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_filepath(filename, extension): | |
return f'{filename}{extension}' | |
class Greeter(hello_pb2_grpc.GreeterServicer): | |
.... | |
def UploadFile(self, request_iterator, context): | |
data = bytearray() | |
filepath = 'dummy' | |
for request in request_iterator: | |
if request.metadata.filename and request.metadata.extension: | |
filepath = get_filepath(request.metadata.filename, request.metadata.extension) | |
continue | |
data.extend(request.chunk_data) | |
with open(filepath, 'wb') as f: | |
f.write(data) | |
return hello_pb2.StringResponse(message='Success!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment