def upload_url(self): url = request.form['url'] f = URLFile() try: success = f.download(url) except: return {'error': 400}, 400 if not success: return {'error': 404}, 404 return _upload_f(f, f.filename)
def upload_url(self): url = request.form['url'] f = URLFile() try: success = f.download(url) except: return {'error': 400}, 400 if not success: return {'error': 404}, 404 result, status = upload(f, f.filename) r.set(_k("url.%s" % url), result) return _upload_object(result, status)
def upload_url(self): if is_tor(): return {'error': 420}, 420 url = request.form['url'] f = URLFile() try: success = f.download(url) except FileTooBig: return {'error': 413}, 413 except Exception: return {'error': 400}, 400 if not success: return {'error': 404}, 404 result, status = upload(f, f.filename) r.set(_k("url.%s" % url), result) return _upload_object(result, status)
def upload_url(self): url = request.form['url'] f = URLFile() try: success = f.download(url) except: return {'error': 400}, 400 if not success: return {'error': 404}, 404 result = _upload_f(f, f.filename) h = None if isinstance(result, dict) and 'hash' in result: h = result['hash'] elif isinstance(result, tuple) and 'hash' in result[0]: h = result[0]['hash'] if h: r.set(_k("url.%s" % url), h) return result