From f0c85526681e913e5130366f43110879a3d23f61 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 8 Sep 2015 10:29:28 -0400 Subject: [PATCH] Remove uses of _external for url_for Fixes #439 --- data/userfiles.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/data/userfiles.py b/data/userfiles.py index f4b786df5..6ad461df6 100644 --- a/data/userfiles.py +++ b/data/userfiles.py @@ -1,11 +1,13 @@ import os import logging import magic +import urlparse from uuid import uuid4 from flask import url_for, request, send_file, make_response, abort from flask.views import View from _pyio import BufferedReader +from util import get_app_url logger = logging.getLogger(__name__) @@ -77,7 +79,9 @@ class DelegateUserfiles(object): if url is None: with self._app.app_context() as ctx: ctx.url_adapter = self._build_url_adapter() - return (url_for(self._handler_name, file_id=file_id, _external=True), file_id) + file_relative_url = url_for(self._handler_name, file_id=file_id) + file_url = urlparse.urljoin(get_app_url(self._app.config), file_relative_url) + return (file_url, file_id) return (url, file_id) @@ -97,7 +101,8 @@ class DelegateUserfiles(object): if url is None: with self._app.app_context() as ctx: ctx.url_adapter = self._build_url_adapter() - return url_for(self._handler_name, file_id=file_id, _external=True) + file_relative_url = url_for(self._handler_name, file_id=file_id) + return urlparse.urljoin(get_app_url(self._app.config), file_relative_url) return url