Skip to content

Add support for installing assets to a file path.#189

Open
cardi wants to merge 1 commit into
chriskuehl:mainfrom
cardi:upload-assets-static
Open

Add support for installing assets to a file path.#189
cardi wants to merge 1 commit into
chriskuehl:mainfrom
cardi:upload-assets-static

Conversation

@cardi

@cardi cardi commented May 6, 2026

Copy link
Copy Markdown

Proposed fix for #24.

This would require a new asset_path in the STORAGE_BACKEND dict.

Example settings.py:

# fluffy-specific configuration options
# storage backend (how are the files stored after being uploaded?)
STORAGE_BACKEND = {
    'name': 'file',
    'object_path': 'tmp/object/{name}',
    'html_path': 'tmp/html/{name}',
    'asset_path': 'tmp/assets/{name}',
}

# branding
BRANDING = 'fluffy'
CUSTOM_FOOTER_HTML = None

# URL patterns
HOME_URL = 'http://localhost:5000/'
FILE_URL = 'http://localhost:4999/object/{name}'
HTML_URL = 'http://localhost:4999/html/{name}'

STATIC_ASSETS_URL = 'http://localhost:4999/assets/{name}'

# abuse contact email address
ABUSE_CONTACT = 'abuse@example.com'

# max upload size per request (in bytes)
MAX_UPLOAD_SIZE = 10 * 1048576  # 10 MB

# max size Flask will accept; maybe a little larger?
MAX_CONTENT_LENGTH = MAX_UPLOAD_SIZE * 10

and a diff with settings/dev_files.py:

diff --git i/settings/dev_files.py w/settings/dev_files.py
index 8fbe50d..8b080ab 100644
--- i/settings/dev_files.py
+++ w/settings/dev_files.py
@@ -4,6 +4,7 @@ STORAGE_BACKEND = {
     'name': 'file',
     'object_path': 'tmp/object/{name}',
     'html_path': 'tmp/html/{name}',
+    'asset_path': 'tmp/assets/{name}',
 }

 # branding
@@ -15,7 +16,7 @@ HOME_URL = 'http://localhost:5000/'
 FILE_URL = 'http://localhost:4999/object/{name}'
 HTML_URL = 'http://localhost:4999/html/{name}'

-STATIC_ASSETS_URL = 'http://localhost:5000/{name}'
+STATIC_ASSETS_URL = 'http://localhost:4999/assets/{name}'

 # abuse contact email address
 ABUSE_CONTACT = 'abuse@example.com'

I'm not sure if settings/dev_files.py should be updated, since the dev environment uses Flask to serve static assets. Perhaps it could go into a new settings/prod_files.py?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant