Python feature suggestion - load (binary) content from file

Ana Nelson nelson.ana at gmail.com
Sun Apr 10 10:49:06 EDT 2011


I've just implemented this in a project:

            binary_data = open(self.filename(), "rb").read()
            mimetype, encoding = mimetypes.guess_type(self.filename())
            if not mimetype:
                mimetype = 'application/octet-stream' # Riak's own default
            self.riak_object = self.bucket.new_binary(
                self.hashstring,
                binary_data,
                mimetype
            )


which writes binary data to a Riak bucket from a file, using Python's
mimetypes library to determine the content type from the file's extension.

I think it could be convenient to have this be included in the Riak Python
client, so perhaps it can implement better buffering. Something like
bucket.new_binary_from_file(key, filename)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20110410/0e8a636e/attachment.html>


More information about the riak-users mailing list