diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/soledad/server/_blobs.py | 10 | ||||
-rw-r--r-- | src/leap/soledad/server/interfaces.py | 16 |
2 files changed, 9 insertions, 17 deletions
diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py index 2ba3fe91..bf370979 100644 --- a/src/leap/soledad/server/_blobs.py +++ b/src/leap/soledad/server/_blobs.py @@ -78,12 +78,12 @@ class FilesystemBlobsBackend(object): def __touch(self, path): open(path, 'a') - def read_blob(self, user, blob_id, request, namespace=''): + def read_blob(self, user, blob_id, namespace=''): logger.info('reading blob: %s - %s@%s' % (user, blob_id, namespace)) path = self._get_path(user, blob_id, namespace) logger.debug('blob path: %s' % path) - _file = static.File(path, defaultType='application/octet-stream') - return _file.render_GET(request) + res = static.File(path, defaultType='application/octet-stream') + return res def get_flags(self, user, blob_id, namespace=''): path = self._get_path(user, blob_id, namespace) @@ -295,8 +295,8 @@ class BlobsResource(resource.Resource): # 404 - Not Found request.setResponseCode(404) return "Blob doesn't exists: %s" % blob_id - return self._handler.read_blob(user, blob_id, request, - namespace=namespace) + res = self._handler.read_blob(user, blob_id, namespace=namespace) + return res.render_GET(request) def render_DELETE(self, request): logger.info("http put: %s" % request.path) diff --git a/src/leap/soledad/server/interfaces.py b/src/leap/soledad/server/interfaces.py index 430cdec3..3274dfdf 100644 --- a/src/leap/soledad/server/interfaces.py +++ b/src/leap/soledad/server/interfaces.py @@ -30,27 +30,19 @@ class IBlobsBackend(Interface): ``twisted.web.server.Request`` and should use them to serve the Blobs API. """ - def read_blob(user, blob_id, request, namespace=''): + def read_blob(user, blob_id, namespace=''): """ - Read a blob from the backend storage and write it as a response to a - request. + Read a blob from the backend storage return it as a twisted resource. :param user: The id of the user who owns the blob. :type user: str :param blob_id: The id of the blob. :type blob_id: str - :param request: A representation of all of the information about the - request that is being made. - :type request: twisted.web.server.Request :param namespace: An optional namespace for the blob. :type namespace: str - :return: Either ``server.NOT_DONE_YET`` to indicate an asynchronous - operation or a ``bytes`` instance to write as the response to the - request. If ``NOT_DONE_YET`` is returned, at some point later (for - example, in a Deferred callback) call ``request.write(b"data")`` to - write data to the request, and ``request.finish()`` to send the - data to the browser. + :return: The blob as a twisted resource. + :rtype: twisted.web.resource.Resource """ def write_blob(user, blob_id, request, namespace=''): |