R
Railway

✋|help

Files on mounted volume not available after redeploy

Iimcorfitz9/15/2023
I did a fresh deploy of @Brody 's Payload CMS template (https://github.com/brody192/payload-cms-template), but when redeployed, the media files uploaded are not available.
Iimcorfitz9/15/2023
5e42a962-c3b7-4238-926e-ffa87df21892
Iimcorfitz9/15/2023
AH!!! It doesn't even add to the volume..
Iimcorfitz9/15/2023
This is my solution:

import path from "path";
const dev = process.env.NODE_ENV !== "production";

export default function volumePath(directory: string) {
  const prodPath = process.env.VOLUME_PATH || `/home/node/app/uploads`;
  return dev
    ? path.resolve(__dirname, `../../uploads/${directory}`)
    : path.resolve(prodPath, directory);
}

And in the Media config file:
import volumePath from "../utilities/volumePath";

const Media: CollectionConfig = {
  slug: "media",
  access: {
    // Payload's access control functions apply to files also, meaning you can permit or deny file downloads easily
    read: () => true,
    create: () => true,
    update: () => true,
    delete: () => true,
  },
  admin: {
    useAsTitle: "filename",
    description: "upload media",
    group: "Content",
  },
  upload: {
    adminThumbnail: "thumbnail",
    imageSizes: [
      {
        name: "thumbnail",
        width: 150,
      },
      {
        name: "normal",
        width: 820,
      },
      {
        name: "wide",
        width: 1400,
      },
      {
        name: "fullscreen",
        width: 1920,
      },
    ],
    staticDir: volumePath("media"),
  },
  fields: [
    {
      name: "alt",
      label: "Alt Text",
      type: "text",
      required: true,
    },
  ],
};

export default Media;
Bbrody1929/15/2023
fixed

Looking for more? Join the community!

Recommended Posts
Can't manually fill MySQLNone of the options i've tried works. I can still create dbs and populate them when connecting throuReferenced variables are emptyIf I hardcode the url in env variables, the deployment is successful, however using a reference to aSetup a monorepoHey guys, I'm using yarn workspaces and turborepo. I tried setting up the build command to "yarn turCan't start Remotion serverWhenever I try to use the Remotion server it cannot open the browser process and shows me this errorRecover a file inside a deploymentBy mistake I left a sqlite file inside a deployment and made a lot of updates to the database on thaDeployment Failed during build processI'm encountering issues while trying to build my Vue 3 and TypeScript project on Railway using NixpaBuild failing without errorMy build is failing to deploy without any error. Its just saying the container failed to start. The Cloudflare detected but not redirectingI've put the the right dns settings in cloudflare NS into godaddy. see screenshot which should poinFailed to authenticate to mongodbDeploying a MongoDB database from the UI, automatically creates a database named "test" if you connePrivate NPM Registry (GitHub)I'm using Yarn 3, GitHub Packages, and NodeJS. I am testing a deploy with `railway up` and when it gDjango advice neededHello good people, i would like to know how can i get some support for Railway? I started with a basUpdate TypebotHello, how i can update my project of typebot without lose all? i am new user in railwayWho deleted our database?I am writing to inquire about the recent deletion of the MySQL database in our account, we noticed Dockerbuild failes with no matching versionI attached the error and the dockerfile. The dockerfile locally runs withouth error but on railway ifailed opening connection to sql: default addr for networkHi, I am trying to deploy my golang web service which connects to mysql. I have added the mysql url Deploying Meilisearch template does not workI have a running project, If I click on new -> template -> Meili then a new service is created. Howe