Ejemplo n.º 1
0
def file_load(img_sha1):
    user = model(ident=session['username'], pwd=session['password'])
    try:
        the_file = CMS.FileService().load(img_sha1)
        if not the_file['success']:
            return the_file['error']
        if request.headers.get('If-Modified-Since') == the_file['time'].ctime():
            return Response(status=304)
        resp = Response(the_file['data'], mimetype='image/' + the_file['mime'])
        resp.headers['Last-Modified'] = the_file['time'].ctime()
        return resp
    except Exception, e:
        print e
        abort(404)
Ejemplo n.º 2
0
def file_upload():
    if not session.get('is_login', False):
        return redirect(URL_BASE + '/login')
    user = model(ident=session['username'], pwd=session['password'])
    if request.method == 'GET':
        return '''
<!doctype html>
<html>
<body>
<form action='/control/file_upload' method='post' enctype='multipart/form-data'>
 <input type='file' name='fileList'>
 <input type='submit' value='Upload'>
</form>
'''
    elif request.method == 'POST':
        f = request.files['fileList']
        db_data = CMS.FileService().save(f)
        return db_data['sha1']
Ejemplo n.º 3
0
def file_list():
    if not session.get('is_login', False):
        return redirect(URL_BASE + '/login')
    user = model(ident=session['username'], pwd=session['password'])
    return CMS.FileService().file_list(json.loads(json.dumps(request.form)), return_type='str')
Ejemplo n.º 4
0
 def images(self):
     from core import CMS
     return CMS.FileService()