Improves support for attaching files and photos to posts; files stay attached if you save as a draft and later publish.
Instead of uploading images to {app.root_path}/_data/{post.path}/files/{filename} I'm uploading them to app.config['UPLOAD_PATH']/{year}/{month}/{day}/{random-string}-{filename} and saving a reference in the post.attachments object.
So the on-disk location is no longer dependent on the post's slug, but it still should be specific enough that if the database were ever lost, we could still mostly reconstruct the post <-> file relationships. It's probably also a good thing that uploaded files are now stored outside of the executable code directory.
@thedod @zachdonovan @Lancey6 Migrating is a pain in the butt. I apologize :/
backup your database and redwind/_data directory somewhere
Update your redwind.cfg file with UPLOAD_PATH and IMAGEPROXY_PATH pointing to the full paths of where you want to store those things on disk. I use
update your nginx configuration to point to the new locations
location /internal_data/ {
internal;
alias /srv/www/kylewm.com/uploads/;
expires 30d;
}
location /internal_imageproxy/ {
internal;
alias /srv/www/kylewm.com/imageproxy/;
expires 1d;
}
backup your redwind/_data directory somewhere
run ./manage.py db upgrade to add the attachments table to the database
run python scripts/convert_files_to_attachments.py to process existing photos and files and convert them to first-class attachments. (I couldn't figure out how to include this script as part of the alembic migration... help appreciated)
reload nginx and restart redwind and hope for the best!
Improves support for attaching files and photos to posts; files stay attached if you save as a draft and later publish.
Instead of uploading images to
{app.root_path}/_data/{post.path}/files/{filename}
I'm uploading them toapp.config['UPLOAD_PATH']/{year}/{month}/{day}/{random-string}-{filename}
and saving a reference in the post.attachments object.So the on-disk location is no longer dependent on the post's slug, but it still should be specific enough that if the database were ever lost, we could still mostly reconstruct the post <-> file relationships. It's probably also a good thing that uploaded files are now stored outside of the executable code directory.
@thedod @zachdonovan @Lancey6 Migrating is a pain in the butt. I apologize :/
UPLOAD_PATH
andIMAGEPROXY_PATH
pointing to the full paths of where you want to store those things on disk. I use./manage.py db upgrade
to add the attachments table to the databasepython scripts/convert_files_to_attachments.py
to process existing photos and files and convert them to first-class attachments. (I couldn't figure out how to include this script as part of the alembic migration... help appreciated)