From a756632cad1129c2203500992da62cbf3571b595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 8 Jan 2019 14:13:30 +0100 Subject: [PATCH] Added pillar.api.projects.utils.storage(project_id) function For now this returns a bucket in the default storage backend, since individual projects do not have a 'storage backend' setting (this is set per file, not per project). --- pillar/api/projects/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pillar/api/projects/utils.py b/pillar/api/projects/utils.py index a33305ed..f85d8fc5 100644 --- a/pillar/api/projects/utils.py +++ b/pillar/api/projects/utils.py @@ -7,6 +7,7 @@ from werkzeug.exceptions import abort from pillar import current_app from pillar.auth import current_user +from pillar.api import file_storage_backends log = logging.getLogger(__name__) @@ -187,3 +188,14 @@ def put_project(project: dict): if status_code != 200: raise ValueError(f"Can't update project {pid}, " f"status {status_code} with issues: {result}") + + +def storage(project_id: ObjectId) -> file_storage_backends.Bucket: + """Return the storage bucket for this project. + + For now this returns a bucket in the default storage backend, since + individual projects do not have a 'storage backend' setting (this is + set per file, not per project). + """ + + return file_storage_backends.default_storage_backend(str(project_id))