Python Thrift server send zip file

I would like to create a Thrift server which is handling, storing and extracting file uploads from client. I tried to find a sample, tutorial but I can't find anything. Client sending it is as binary but on server side it will be string. What is the problem?

But I got an error:

ERROR:root:file() argument 1 must be encoded string without null bytes, not str
Traceback (most recent call last):
  File "gen-py/api_definitions/API.py", line 204, in process_analyze
    result.success = self._handler.upload(args.files)
  File "remote.py", line 73, in analyze
    with ZipFile(zip_file, 'r') as zip:
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 756, in __init__
    self.fp = open(file, modeDict[mode])
TypeError: file() argument 1 must be encoded string without null bytes, not str

Server code:

#!/usr/bin/env python

import sys
import json
import ast
sys.path.append('gen-py')

from api_definitions import API
from api_definitions.ttypes import *

from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer

import socket
import subprocess
import logging

from zipfile import ZipFile 

logger = logging.getLogger('Remote CodeChecker')
logger.setLevel(logging.INFO)
# create file handler that logs debug and higher level messages
fh = logging.FileHandler('server.log')
fh.setLevel(logging.DEBUG)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
# create formatter and add it to the handlers
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
fh.setFormatter(formatter)
# add the handlers to logger
logger.addHandler(ch)
logger.addHandler(fh)


class APIHandler:
    def __init__(self):
        self.log = {}

    def upload(self, command, zip_file):
        logger.info('Analyze')

        logger.info(type(zip_file))
        logger.info(zip_file)

        with ZipFile(zip_file, 'r') as zip:
            zip.printdir() 

            # extracting all the files 
            logger.info('Extracting all the files now...') 
            zip.extractall() 

        zip_ref = zipfile.ZipFile(path_to_zip_file, 'r')
        zip_ref.extractall(directory_to_extract_to)
        zip_ref.close()

        return "..."


handler = APIHandler()
processor = API.Processor(handler)
transport = TSocket.TServerSocket(port=8000)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()

server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)

logger.info('Starting server...')
server.serve()
logger.info('Server stopped!')

Client code:

#!/usr/bin/env python

import sys
sys.path.append('gen-py')

from api_definitions import API
from api_definitions.ttypes import *
from api_definitions.constants import *

from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol

import logging

logger = logging.getLogger('Call CodeChecker')
logger.setLevel(logging.INFO)
# create file handler that logs debug and higher level messages
fh = logging.FileHandler('client.log')
fh.setLevel(logging.DEBUG)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
# create formatter and add it to the handlers
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
fh.setFormatter(formatter)
# add the handlers to logger
logger.addHandler(ch)
logger.addHandler(fh)

try:
    # Make socket
    transport = TSocket.TSocket('localhost', 8000)

    # Buffering is critical. Raw sockets are very slow
    transport = TTransport.TBufferedTransport(transport)

    # Wrap in a protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)

    # Create a client to use the protocol encoder
    client = API.Client(protocol)

    # Connect!
    transport.open()

    with open("test.cpp_40d8232dd7463ca0fbd0cae800b6a1b3.plist.zip", "rb") as binary_file:
        zip_file = binary_file.read()

    msg = client.upload(zip_file)
    logger.info(msg)

    transport.close()

except Thrift.TException, tx:
    logger.info("%s" % (tx.message))

Thrift file:

service API {
    binary upload(1: binary files)
}