I am using the Python Box API to write some tools. Therefore, one of them is to upload the file to Box . They use StringIO as an object file. I need to read the file locally and write its contents to the StringIO buffer, and then pass this to the API Box , as shown in the code below:
def upload_file(self, filename, folder_id='0'): assert self.client is not None try: stream = StringIO.StringIO()
Simple enough, how can I read from a local file and then write to StringIO buffer?
source share