diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-03-24 17:41:45 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-03-24 19:09:18 +0200 |
commit | a3ef8c3ddfb24d78431172f84015d02422fa9f99 (patch) | |
tree | ff954dfdcaf368e23c9526cf8093262780fc9930 /ick2/blobapi.py | |
parent | 78d9c80226c52bcd70e27e7ee2a3a7754f644b53 (diff) | |
download | ick2-a3ef8c3ddfb24d78431172f84015d02422fa9f99.tar.gz |
Change: handle up/downloads of large blobs
Diffstat (limited to 'ick2/blobapi.py')
-rw-r--r-- | ick2/blobapi.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/ick2/blobapi.py b/ick2/blobapi.py index 1772a27..0969c90 100644 --- a/ick2/blobapi.py +++ b/ick2/blobapi.py @@ -1,4 +1,4 @@ -# Copyright 2017 Lars Wirzenius +# Copyright 2017-2018 Lars Wirzenius # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -14,6 +14,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import apifw + + import ick2 @@ -35,6 +38,7 @@ class BlobAPI: 'method': 'PUT', 'path': path, 'callback': self.put_blob, + 'big-blobs': True, }, { 'method': 'GET', @@ -46,17 +50,12 @@ class BlobAPI: def put_blob(self, content_type, body, blob_id, **kwargs): ick2.log.log( 'info', msg_text='blob uploaded', blob_id=blob_id, kwargs=kwargs) - self._blobs.store_blob(blob_id, body) + self._blobs.store_blob_from_reader(blob_id, body) return ick2.OK('') def get_blob(self, content_type, body, blob_id, **kwargs): + filename = self._blobs.blob_filename(blob_id) ick2.log.log( - 'info', msg_text='blob requested', blob_id=blob_id, kwargs=kwargs) - try: - blob = self._blobs.get_blob(blob_id) - except EnvironmentError as e: - return ick2.not_found(str(e)) - headers = { - 'Content-Type': 'application/octet-stream', - } - return ick2.OK(blob, headers=headers) + 'info', msg_text='blob requested', blob_id=blob_id, kwargs=kwargs, + filename=filename) + raise apifw.StaticFile(filename) |