code: def new_from_file(self, key, filename):
          
          binary_data = None
          with open(filename, 'rb') as f:
              binary_data = f.read()
          mimetype, encoding = mimetypes.guess_type(filename)
          if encoding:
              binary_data = bytearray(binary_data, encoding)
          else:
              binary_data = bytearray(binary_data)
          if not mimetype:
              mimetype = 'application/octet-stream'
          if PY2:
              return self.new(key, encoded_data=binary_data,
                              content_type=mimetype)
          else:
              return self.new(key, encoded_data=bytes(binary_data),
                              content_type=mimetype)
docs: Create a new Riak object in the bucket, using the contents of
          the specified file. This is a shortcut for :meth:`new`, where the
          ``encoded_data`` and ``content_type`` are set for you.
  
          .. warning:: This is not supported for buckets that contain
             :class:`Datatypes <riak.datatypes.Datatype>`.
  
          :param key: the key of the new object
          :type key: string
          :param filename: the file to read the contents from
          :type filename: string
          :rtype: :class:`RiakObject <riak.riak_object.RiakObject>`