summary refs log tree commit diff
path: root/synapse/media/v1/download_resource.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-01-07 14:34:00 +0000
committerErik Johnston <erik@matrix.org>2015-01-07 14:34:00 +0000
commitbacaa215eb2e1c11e50bbc3fb0e43e28a463458b (patch)
tree27510a6358b8bc219ccd456622b963a3b394bee3 /synapse/media/v1/download_resource.py
parentMerge branch 'hotfixes-v0.6.0a' (diff)
parentImprove change log (diff)
downloadsynapse-bacaa215eb2e1c11e50bbc3fb0e43e28a463458b.tar.xz
Merge branch 'release-v0.6.1' of github.com:matrix-org/synapse v0.6.1
Diffstat (limited to 'synapse/media/v1/download_resource.py')
-rw-r--r--synapse/media/v1/download_resource.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/synapse/media/v1/download_resource.py b/synapse/media/v1/download_resource.py
index f3a6804e05..c585bb11f7 100644
--- a/synapse/media/v1/download_resource.py
+++ b/synapse/media/v1/download_resource.py
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright 2014 OpenMarket Ltd
+# Copyright 2014, 2015 OpenMarket Ltd
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -46,23 +46,29 @@ class DownloadResource(BaseMediaResource):
     def _respond_local_file(self, request, media_id):
         media_info = yield self.store.get_local_media(media_id)
         if not media_info:
-            self._respond_404()
+            self._respond_404(request)
             return
 
         media_type = media_info["media_type"]
+        media_length = media_info["media_length"]
         file_path = self.filepaths.local_media_filepath(media_id)
 
-        yield self._respond_with_file(request, media_type, file_path)
+        yield self._respond_with_file(
+            request, media_type, file_path, media_length
+        )
 
     @defer.inlineCallbacks
     def _respond_remote_file(self, request, server_name, media_id):
         media_info = yield self._get_remote_media(server_name, media_id)
 
         media_type = media_info["media_type"]
+        media_length = media_info["media_length"]
         filesystem_id = media_info["filesystem_id"]
 
         file_path = self.filepaths.remote_media_filepath(
             server_name, filesystem_id
         )
 
-        yield self._respond_with_file(request, media_type, file_path)
+        yield self._respond_with_file(
+            request, media_type, file_path, media_length
+        )