Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

async mongodb gridfs with tornado IOLoop

Project Description
asyncgridfs
===========

async mongo gridfs for tornado


Installation
------------

Installing: `pip install asyncgridfs` or ` easy_install asyncgridfs`


Usage
-----

import asyncmongo
import tornado.web
from asyncgridfs import GridFS

class Handler(tornado.web.RequestHandler):
@property
def db(self):
if not hasattr(self, '_db'):
self._db = asyncmongo.Client(pool_id='mydb', host='127.0.0.1', port=27017, maxcached=10, maxconnections=50, dbname='test')
return self._db

@tornado.web.asynchronous
def get(self):
fid = self.get_argument('fid')
fs = GridFS(self.db)
fs.get(ObjectId(fid),callback=self._on_get)


@tornado.web.asynchronous
def post(self):
f = self.request.files['imgFile'][0]
content = f.pop('body')
content_type = f.pop('content_type')
filename = f.pop('filename')

fs = GridFS(self.db)
fs.put(content, contentType=content_type, filename=filename, callback=self._on_post)


def _on_get(self, fileobj):
self.set_header('Content-Type', fileobj['contentType'])
self.write(fileobj['data'])
self.finish()

def _on_put(self, _id):
self.write(str(_id))
self.finish()
Release History

Release History

This version
History Node

0.2.1.dev

History Node

0.2.dev

History Node

0.1.dev

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
asyncgridfs-0.2.1.dev-py2.7.egg (6.7 kB) Copy SHA256 Checksum SHA256 2.7 Egg May 17, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting