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.

Can't access media after rebuild?

default discord avatar
.kilosierralast year
19

After making some changes and redeploying payload, why can't I access media files?

  • default discord avatar
    notchrlast year

    If you right click on an image and grab the URL



    Is it the path you're expecting?



    Did you change any URL configurations?



    Permissions, etc



    @979424432797913088
  • default discord avatar
    .kilosierralast year

    The image path is correct. I also didn't change any url configurations. I added uploads to my user collection and redeployed to railway.

  • default discord avatar
    notchrlast year

    But the image path returns a 404?



    I would check permissions on the upload collection



    Permissions on the folder



    as well

  • default discord avatar
    .kilosierralast year

    Correct, it returns 404. The permissons haven't changed. This happens every time I do a redeploy

  • default discord avatar
    notchrlast year

    What are the folder permissions



    wondering if they are somehow altered on deploy

  • default discord avatar
    .kilosierralast year

    read



  • default discord avatar
    notchrlast year

    hmm



    Wondering if it is a static dir issue



    I've had issues where I've had to add an nginx block for uploads



    But you're saying it works sometimes, or hasnt yet?

  • default discord avatar
    .kilosierralast year

    It has never worked on a redeploy. Even when I first set things up locally it didn't work on the first deploy

  • default discord avatar
    notchrlast year

    Can you adjust your nginx settings on railway



    out of curiosity



    or was that configured automatically

  • default discord avatar
    .kilosierralast year

    There's no mention of nginx in the railway docs



    I'm assuming it's configured automatically

  • default discord avatar
    notchrlast year

    I am seeing some previous posts here about Railway and inconsistent file storage



    This may not still be the case



    But it may be useful to search this discord channel for Railway



    And see if anyone has resolved issues pertaining to media / uploads

  • default discord avatar
    .kilosierralast year

    There's no mention of this issue on this doscord channel



    I've been in touch with railway and bizarrely they don't offer persistent storage yet. However, they've released persistent storage as a feature for users on their beta testing program.

  • discord user avatar
    denolfe
    last year

    Your payload instance is likely writing to Railway's ephemeral disk, then on redeploy it gets completely blown away



    Might have to hook up some cloud storage via

    https://github.com/payloadcms/plugin-cloud-storage
  • default discord avatar
    .kilosierralast year

    The media is in MongoDB Atlas along with my posts which display fine after a redeploy. So why would my media not show but my posts do when both are in a database on a separate cloud service?



  • default discord avatar
    leonardstrucklast year

    When you redeploy Payload on Railway, the images are disappearing because the actual binary data of the images is stored in the file system, not in MongoDB.



    During the redeployment process, the file system may get reset or modified, resulting in the loss of the image files. To avoid this issue, there are a couple of options you can consider:



    1. Create a persistent mount on Railway: If possible, you can configure Railway to use a persistent storage solution where the image files are stored. This way, even after redeployments, the image files will remain intact.


    2. Use the Payload storage plugin as Elliot suggested.

  • default discord avatar
    .kilosierralast year

    I've used the payload cloud plugin with an S3 bucket as suggested and this has solved the issue. However, the issue now is the slow loading times of the images. I've setup a CloudFront CDN for the S3 bucket but I can't find any information on how to use my S3 bucket with payload via the CDN

  • discord user avatar
    denolfe
    last year

    Just to clarify, you've configured the cloud-storage-plugin for your own S3 bucket, but the loading times are slow, and you'd like to configure a CDN somehow?

  • default discord avatar
    .kilosierralast year

    correct

  • discord user avatar
    denolfe
    last year

    This seems like a duplicate of your thread over here. We'll continue there.

    https://discord.com/channels/967097582721572934/1125374059690078278
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.