def show_thumbnail(url): upload = get_upload(current_user, url) if isinstance(upload, int): abort(upload) obj = upload.object r = make_response() r.headers['Cache-Control'] = 'public' r.headers['Content-Type'] = '' r.headers['Content-Disposition'] = 'inline; filename="%s"' % upload.title.encode('utf8') r.headers['X-Accel-Redirect'] = imgtl.lib.get_spath('/x/thumb', obj.code) return r
def show_thumbnail(url): upload = get_upload(current_user, url) if isinstance(upload, int): abort(upload) obj = upload.object r = make_response() r.headers['Cache-Control'] = 'public' r.headers['Content-Type'] = '' r.headers[ 'Content-Disposition'] = 'inline; filename="%s"' % upload.title.encode( 'utf8') r.headers['X-Accel-Redirect'] = imgtl.lib.get_spath('/x/thumb', obj.code) return r
def show_only_image(url, ext): upload = get_upload(current_user, url) if isinstance(upload, int): abort(upload) obj = upload.object if isinstance(obj, Image): if obj.ext != ext: abort(404) r = make_response() r.headers['Cache-Control'] = 'public' r.headers['Content-Type'] = '' r.headers['Content-Disposition'] = 'inline; filename="%s"' % upload.title.encode('utf8') r.headers['X-Accel-Redirect'] = imgtl.lib.get_spath('/x', obj.code) return r
def show_only_image(url, ext): upload = get_upload(current_user, url) if isinstance(upload, int): abort(upload) obj = upload.object if isinstance(obj, Image): if obj.ext != ext: abort(404) r = make_response() r.headers['Cache-Control'] = 'public' r.headers['Content-Type'] = '' r.headers[ 'Content-Disposition'] = 'inline; filename="%s"' % upload.title.encode( 'utf8') r.headers['X-Accel-Redirect'] = imgtl.lib.get_spath('/x', obj.code) return r
def show(url): if request.method == 'DELETE': res = do_delete_image(current_user, url) if res == 'success': flash(i18n('deletesuccess'), 'success') return jsonify({'res': res}) elif request.method == 'PUT': res = do_update_image(current_user, url, request.form.get('nsfw') == 'true', request.form.get('anonymous') == 'true', request.form.get('private') == 'true') return jsonify({'res': res}) elif request.method == 'GET': upload = get_upload(current_user, url) if isinstance(upload, int): abort(upload) obj = upload.object if isinstance(obj, Image): return render_imgtl_template('show/image.html', upload=upload)
def get(self, url): upload = get_upload(None, url) if not upload or upload.deleted: return error('nosuchupload'), 404 user = { 'name': upload.user.name, 'profile_image_url': upload.user.profile_image_url } if upload.user else None return success({ 'type': upload.object.__tablename__, 'url': { 'page': BASE_URL % upload.url, 'direct': upload.direct_url }, 'title': upload.title, 'desc': upload.desc, 'upload_at': upload.time.strftime('%s'), 'user': user, 'view_count': upload.view_count, 'properties': upload.object.prop })
def get(self, url): upload = get_upload(None, url) if not upload or upload.deleted: return error('nosuchupload'), 404 user = {'name': upload.user.name, 'profile_image_url': upload.user.profile_image_url} if upload.user else None return success({'type': upload.object.__tablename__, 'url': {'page': BASE_URL % upload.url, 'direct': upload.direct_url}, 'title': upload.title, 'desc': upload.desc, 'upload_at': upload.time.strftime('%s'), 'user': user, 'view_count': upload.view_count, 'properties': upload.object.prop})