diff --git a/apps/addons/buttons.py b/apps/addons/buttons.py
index 69dcdcabf7..adb23ee5b8 100644
--- a/apps/addons/buttons.py
+++ b/apps/addons/buttons.py
@@ -137,7 +137,7 @@ class InstallButton(object):
self.addon.status == file.status == amo.STATUS_PUBLIC):
url = file.latest_xpi_url()
else:
- url = file.get_url_path(self.src)
+ url = file.get_url_path(self.app, self.src)
if platform == amo.PLATFORM_ALL.id:
text, os = _('Download Now'), None
diff --git a/apps/api/templates/api/includes/addon.xml b/apps/api/templates/api/includes/addon.xml
index 9e22b07675..7c7d7b918f 100644
--- a/apps/api/templates/api/includes/addon.xml
+++ b/apps/api/templates/api/includes/addon.xml
@@ -68,7 +68,7 @@
{%- for file in addon.current_version.all_files -%}
{{ file.get_url_path('api') }}
+ size="{{ file.size * 1024 }}">{{ file.get_url_path(APP, 'api') }}
{% endfor -%}
{%- endif -%}
{%- if api_version >= 1.5 %}
@@ -77,7 +77,7 @@
- {{ file.get_url_path('api') }}
+ {{ file.get_url_path(APP, 'api') }}
{% endfor -%}
{%- endif -%}
diff --git a/apps/files/models.py b/apps/files/models.py
index 5fcc5e8f08..cc0d144714 100644
--- a/apps/files/models.py
+++ b/apps/files/models.py
@@ -2,6 +2,7 @@ import os
from django.conf import settings
from django.db import models
+from django.utils import translation
import amo.models
from amo.urlresolvers import reverse
@@ -24,9 +25,11 @@ class File(amo.models.ModelBase):
class Meta(amo.models.ModelBase.Meta):
db_table = 'files'
- def get_url_path(self, src):
+ def get_url_path(self, app, src):
from amo.helpers import urlparams
- base = settings.FILES_URL % (self.id, self.filename, src)
+ lang = translation.get_language()
+ base = settings.FILES_URL % (lang, app.short, self.id,
+ self.filename, src)
return urlparams(base, confirmed=1)
def latest_xpi_url(self):
diff --git a/apps/files/tests.py b/apps/files/tests.py
index 59d07042b1..784dd3e413 100644
--- a/apps/files/tests.py
+++ b/apps/files/tests.py
@@ -2,6 +2,7 @@ from django import test
from nose.tools import eq_
+import amo
from files.models import File
@@ -14,9 +15,10 @@ class TestFile(test.TestCase):
def test_get_absolute_url(self):
f = File.objects.get(id=11993)
- assert f.get_absolute_url(src='src').endswith(
- 'downloads/file/11993/'
- 'del.icio.us_bookmarks-1.0.43-fx.xpi?src=src&confirmed=1')
+ url = f.get_absolute_url(amo.FIREFOX, src='src')
+ expected = ('/firefox/downloads/file/11993/'
+ 'del.icio.us_bookmarks-1.0.43-fx.xpi?src=src&confirmed=1')
+ assert url.endswith(expected), url
def test_latest_url(self):
# With platform.
diff --git a/settings.py b/settings.py
index 6e031337c2..b1f605d80b 100644
--- a/settings.py
+++ b/settings.py
@@ -358,7 +358,7 @@ PREVIEW_FULL_URL = (STATIC_URL +
'/img/uploads/previews/full/%s/%d.png?modified=%d')
USER_PIC_URL = STATIC_URL + '/img/uploads/userpics/%s/%s/%s.jpg?modified=%d'
# paths for uploaded extensions
-FILES_URL = STATIC_URL + "/downloads/file/%d/%s?src=%s"
+FILES_URL = STATIC_URL + "/%s/%s/downloads/file/%d/%s?src=%s"
COLLECTION_ICON_URL = ('%s/%s/%s/images/collection_icon/%%s/%%s' %
(STATIC_URL, LANGUAGE_CODE, DEFAULT_APP))
PERSONAS_IMAGE_URL = ('http://getpersonas.com/static/'