Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Images don't persist

default discord avatar
marygracee3 years ago
15

So.


I have my payload project and I created 2 posts, and both have an image.


After adding the images locally, i git add, commit and push to the server.


However, when i log in the online hosted admin dashboard, the images are gone. They are there, but are empty, just the placeholder icon.

  • discord user avatar
    jarrod_not_jared
    3 years ago

    It’s normally best practice to keep images out of your git history (bloats the size of the repo). I would assume that your media folder is in your gitignore file which excludes it from git history. Also assuming you might be using mongo atlas? That would make sense to why the data is there, but the images are not, because they are only on your local machine

  • default discord avatar
    marygracee3 years ago

    So what do you advise? In terms of workflow I mean. Keep the images out of local and only add them through the hosted admin dashboard?

  • discord user avatar
    jarrod_not_jared
    3 years ago

    Possibly spin up another mongo atlas db if possible, for development. That way you can have a prod db and a staging db that is disposable. Not sure what their free tier includes honestly, but that’s normally how we do it 👍

  • default discord avatar
    marygracee3 years ago

    Also as a complete beginner I have a question.


    I have uploaded the payload project to the internet through a hosting server that fetches my github repo.


    When I push the project, the repo is aligned with my local files.


    When I, for example, add a post through the hosted admin dashboard, it means I am "ahead" of the repo? How does that work?



    ill look into that

  • discord user avatar
    jarrod_not_jared
    3 years ago

    ooo maybe your images are not in your gitignore file? What’s the slug of your upload collection?

  • default discord avatar
    marygracee3 years ago
  • discord user avatar
    jarrod_not_jared
    3 years ago

    Ok, so you should add src/media to your gitignore file. The reason the server says it’s ahead of your repo is because when you add an image, it’s adding it to your src/media folder, which you don’t want

  • default discord avatar
    marygracee3 years ago

    the server doesn't say anything. It's just something I thought.


    In the repo, in the media folder I have two images.


    In the hosted admin dashboard those two images were just placeholder icons of google chrome, so I deleted them and added them back through the hosted admin dashboard.


    However those two images still appear in the GitHub repo, even though the hosted payload project is fetched directly through the GitHub repo. I guess it's just how it works but it's a strange concept to me.



    Btw if I add media to gitignore, you're basically telling me it's useless that I attach an image to a post, because that image will eventually disappear when I update the hosted dashboard.



    So this means if I have 1000 posts, with as many pictures, I'll have to re-add those 1000 images every single time, unless I just stop updating the repo and use the hosted dashboard without touching the local again?

  • discord user avatar
    jarrod_not_jared
    3 years ago

    Where are you hosting your site? I’m saying images do not belong in GitHub, they belong on a file system on a server somewhere. If where you are deploying payload does not allow for file hosting then file hosting is something you will need to figure out. I’ve used digital ocean droplets to deploy and store images before, some people use S3 type storage, where the images are hosted elsewhere than the server running payload. Maybe a question for

    #967097582721572937

    to see what everyone else’s setup looks like!

  • default discord avatar
    marygracee3 years ago

    render.com



    Gotcha by the way



    it's a first for me, that's why I have all these questions



    I've only ever used sanity and never had to think about these things

  • discord user avatar
    jarrod_not_jared
    3 years ago

    The questions are totally fine, answering questions on discord is no problem.



    Sanity is a bit different because they own the server, where with payload you own it - which also comes with a little more leg work on your end. We are building Payload cloud that will allow you to get up and running much easier, similar to sanity, but you will still own your code, data and files

  • default discord avatar
    marygracee3 years ago

    Yeah Sanity is a lot easier and beginner friendly. However I have invested so much time in trying to make payload work that I wanna fix this issue with images.



    So I need:


    - mongodb atlas for collections


    - render.com (or, in general, a hosting service)


    - a cloud for media (images and videos)



    Right?



    The last service, do you know one that offers a free tier?

  • discord user avatar
    jarrod_not_jared
    3 years ago

    You have it right, those are the 3 requirements to getting payload up an running, unfortunately I do not know of a free host for files 🫤

  • default discord avatar
    marygracee3 years ago

    I'll give it a google

  • default discord avatar
    leonardstruck3 years ago

    I’ve been using this so far, 10 Gigs are free. Pretty reliable and cheap S3 storage.

    https://www.idrive.com/e2/
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.