Пример #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)
Пример #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)
Пример #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)
Пример #4
0
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
    )
Пример #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)
Пример #6
0
def _get(content):
    if isinstance(content, ObjectId):
        return get_fs().get(content).read()
    return content
Пример #7
0
def _get(content):
    if isinstance(content, ObjectId):
        return get_fs().get(content).read()
    return content