code: def writeFile(self, directory=None):
          
          if directory:
              # If a directory was specified
              full_path = os.path.join(directory, self.filename)
              with open(full_path, 'wb') as f:
                  f.write(pickle.loads(self.data).read())
              return full_path
  
          # if no directory was specified, create a temporary file
          this_file = tempfile.NamedTemporaryFile(delete=False)
          this_file.write(pickle.loads(self.data).read())
          this_file.close()
  
          return this_file.name
docs: Writes back the file to a temporary path (optionaly specified)