Reputation: 53666
We've got wagtail 2.0.1 set up to work with AWS S3 for media files, and that works great for images (uploads are sent to S3, the /images
route shows all images in the image manager), it does not seem to work correctly for documents.
The settings we use:
# Storage for user generated files
if USE_S3:
# Use S3 to store user files if the corresponding environment var is set
DEFAULT_FILE_STORAGE = 'filebrowser_s3.storage.S3MediaStorage'
AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = env('AWS_STORAGE_BUCKET_NAME')
AWS_S3_CUSTOM_DOMAIN = env('AWS_S3_CUSTOM_DOMAIN')
AWS_LOCATION = env('AWS_LOCATION')
MEDIA_URL = 'https://' + AWS_S3_CUSTOM_DOMAIN + '/'
MEDIA_ROOT = ''
FILEBROWSER_DIRECTORY = env('FILEBROWSER_DIRECTORY')
else:
# Otherwise use the default filesystem storage
MEDIA_ROOT = root('media/')
MEDIA_URL = '/media/'
(note that filebrowser_s3
is a small library that extends the S3Boto3Storage class from the s3boto3
library)
We can upload documents, and these end up on S3 in the correct location, with the database getting a file
record that points to the correct path to append to the S3 base location, but the /documents route shows "nothing":
Searching "works" in that it finds results, says there are X results, shows the category the results are in, but then shows nothing else:
Does the document app use a special wagtail constant that we need to set in addition to the media root/url constants, so that wagtail can show the document list with the associated edit/etc UI?
Upvotes: 0
Views: 868
Reputation: 53666
This turned out to be caused by loading the document app, but not having the corresponding url patterns loaded. Running a duplicate of the production S3 buckets against a local wagtail copy with all debug settings turned on showed that there were no reverse rules for what were supposed to be the wagtail document routes, which showed our urls.py was grabbing the patterns from the document app, but did not actually load those patterns as part of the master urlpatterns list.
Upvotes: 1
Reputation: 1451
Does the document app use a special wagtail constant that we need to set in addition to the media root/url constants, so that wagtail can show the document list with the associated edit/etc UI?
No, it doesn't. Could you please try with
pip install django-storages
and
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
? This is the standard approach for Django/Wagtail and S3.
If that works, there may be an issue with filebrowser_s3
.
See also
Upvotes: 0