

def post(self):
    if (not may(CREATE)):
        raise Forbidden()
    f = request.files.get('file')
    t = request.form.get('text')
    if (f and f.filename):
        if ContentRange.from_request():
            abort(416)
        content_type = (f.headers.get('Content-Type') or request.headers.get('Content-Type'))
        content_type_hint = 'application/octet-stream'
        filename = f.filename
        f.seek(0, os.SEEK_END)
        size = f.tell()
        f.seek(0)
    elif (t is not None):
        t = t.encode('utf-8')
        content_type = request.form.get('contenttype')
        content_type_hint = 'text/plain'
        size = len(t)
        f = BytesIO(t)
        filename = request.form.get('filename')
    else:
        raise NotImplementedError
    maxlife_unit = request.form.get('maxlife-unit', 'forever').upper()
    maxlife_value = int(request.form.get('maxlife-value', 1))
    maxtime = time_unit_to_sec(maxlife_value, maxlife_unit)
    maxlife_timestamp = ((int(time.time()) + maxtime) if (maxtime > 0) else maxtime)
    name = create_item(f, filename, size, content_type, content_type_hint, maxlife_stamp=maxlife_timestamp)
    return redirect_next('bepasty.display', name=name, _anchor=url_quote(filename))

dataset/ETHPy150Open bepasty/bepasty-server/bepasty/views/upload.py UploadView.post/original