I have a Django app running on a server. Currently user uploads are stored on the server filesystem.
I already know how to set up S3 storage. What is the best way to migrate existing uploads to S3 without breaking the API and having existing uploads still available?
These files are served to the front end in two ways:
- Directly through a
/media/path/to/upload
endpoint:
/media/<path> django.views.static.serve
- Through a viewset:
/api/v1/users/<user_pk>/items/<item_pk>/attachments/<pk>/ project.app.views.ItemAttachmentsViewSet
Does the following make sense:
- Change the storage backend
- Go through all model objects
- Save each model object to get the files uploaded
- Have
/media/path
go to a new view that will serve the files similar to howItemAttachmentsViewSet
does it. ? Or is there a better way?
The procedure outlined in the question was what I ended up doing, with the exception of step 4 which turned out to be unnecessary.