Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file storage option #12590

Draft
wants to merge 10 commits into
base: release-v0.17.x
Choose a base branch
from
10 changes: 10 additions & 0 deletions kolibri/deployment/default/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"


# File Storage Backend
# https://docs.djangoproject.com/en/3.2/ref/files/storage/

if not os.environ.get("DEFAULT_FILE_STORAGE"):
if conf.OPTIONS["FileStorage"]["STORAGE_BACKEND"] == "file_system":
DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage"
elif conf.OPTIONS["FileStorage"]["STORAGE_BAKCEND"] == "gcloud":
DEFAULT_FILE_STORAGE = "some-other-thing-gotta-figure-that-out"


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

Expand Down
12 changes: 12 additions & 0 deletions kolibri/utils/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from configobj import ConfigObj
from configobj import flatten_errors
from configobj import get_extra_values
from django.core.files.storage import Storage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably why flake8 wouldn't let pre-commit pass but it didn't give me useful output

from django.utils.functional import SimpleLazyObject
from django.utils.module_loading import import_string
from validate import is_boolean
Expand Down Expand Up @@ -359,6 +360,17 @@ def lazy_import_callback_list(value):


base_option_spec = {
"FileStorage": {
"STORAGE_BACKEND": {
"type": "option",
"options": ("file_system", "gcloud"),
"default": "file_system",
"description": """
The storage backend class that Django will use when managing files. The class given here must implement
the Django files.storage.Storage class.
""",
},
},
"Cache": {
"CACHE_BACKEND": {
"type": "cache_option",
Expand Down
Loading