def _put(stream): b = stream.read() digest = sha1(b).hexdigest() size = len(b) try: if stream.getbuffer().nbytes > 2**23: b = get_fs().put(b) except AttributeError: # FIXME: what the actual f**k, mitsuhiko? b = get_fs().put(b) return dict(content=b, digest=digest, short=digest[-6:], size=size)
def _put(stream): b = stream.read() mimetype = magic(b, mime=True).decode("utf-8") digest = sha1(b).hexdigest() try: if stream.getbuffer().nbytes > 2 ** 23: b = get_fs().put(b) except AttributeError: # FIXME: what the actual f**k, mitsuhiko? b = get_fs().put(b) return dict(content=b, digest=digest, mimetype=mimetype)
def _put(stream): b = stream.read() mimetype = magic(b, mime=True).decode('utf-8') digest = sha1(b).hexdigest() try: if stream.getbuffer().nbytes > 2**23: b = get_fs().put(b) except AttributeError: # FIXME: what the actual f**k, mitsuhiko? b = get_fs().put(b) return dict(content=b, digest=digest, mimetype=mimetype)
def _put(stream): b = stream.read() digest = sha1(b).hexdigest() try: if stream.getbuffer().nbytes > 2 ** 23: b = get_fs().put(b) except AttributeError: # FIXME: what the actual f**k, mitsuhiko? b = get_fs().put(b) return dict( content = b, digest = digest )
def _put(stream): b = stream.read() digest = sha1(b).hexdigest() size = len(b) if len(stream.getvalue()) > 2**23: b = get_fs().put(b) return dict(content=b, digest=digest, short=digest[-6:], size=size)
def _get(content): if isinstance(content, ObjectId): return get_fs().get(content).read() return content