Hi , has anyone ever worked with streaming files a...
# grpc
Hi , has anyone ever worked with streaming files as a byte array in grpc (Sending file as list of chunks from client and reconstructing it on the server) ? This is what i have on the client side
Copy code
val chunk = ByteArray(BYTE_ARRAY_SIZE)
val inputStream = FileInputStream(file)
val fileChunks = flow {
	val metadata = MetaData.newBuilder()
	// It works if i dont break the file into chunks 
	// val fileChunk = FileChunk.newBuilder().setData(ByteString.copyFrom(byteArray)).build()
	// emit(FileUploadRequest.newBuilder().setContent(fileChunk).build())
	while(true) {
		val size = inputStream.read(chunk)
		if(size <= 0) break
		val fileChunk = FileChunk.newBuilder()
			.setData(ByteString.copyFrom(chunk, 0, size)).build()
On the server side , i reconstruct the file and process it , the file is constructed properly if i send it all at once instead of breaking it down into smaller chunks. Not sure how to debug this either , does anyone have any idea what i am doing wrong ?
Copy code
requests.collect {
	if (it.hasContent()) {
	} else {
		metadata = it.metadata
		file = File(metadata.path)