Saving django files on volume
ezg0t
HOBBYOP

a year ago

Hello, I want to add user's avatars on volume then show them on my website, this is my settings.py:

STATIC_URL = '/static/'

MEDIAROOT = os.path.join(os.path.dirname(BASEDIR), 'media')

According to https://docs.railway.com/guides/volumes#relative-paths I filled 'Mount Path' like this: "/app/media"
After I upload my avatar everything seems to work, I can see my picture at url:
MYSERVERURL/media/avatar.jpg
but after I redeploy my backend this file is gone

Solved

5 Replies

ezg0t
HOBBYOP

a year ago

4b14485b-37ab-4af7-960c-c4105df21ec3


adam
MODERATOR

a year ago

walk me through your process here. You have your volume mounted to /app/media, you’re uploading an image and saving it to /media/avatar.jpg, and on redeploy the avatar is gone?


adam
MODERATOR

a year ago

Saving images is best done in a cloud bucket rather than in a Railway Volume for ease of external access


adam
MODERATOR

a year ago

Aside from that, you’ve mounted your volume to /app/media but you’re saving images to /media. The images are not being saved to the bucket


adam
MODERATOR

a year ago

!s


Status changed to Solved adam about 1 year ago


Loading...