Example #1
0
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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
File: model.py Project: jstoone/pb
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
    )
Example #5
0
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)
Example #6
0
def _get(content):
    if isinstance(content, ObjectId):
        return get_fs().get(content).read()
    return content
Example #7
0
def _get(content):
    if isinstance(content, ObjectId):
        return get_fs().get(content).read()
    return content