R
Railway15mo ago
Corfitz

Files on mounted volume not available after redeploy

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.
No description
7 Replies
Percy
Percy15mo ago
Project ID: 5e42a962-c3b7-4238-926e-ffa87df21892
Corfitz
CorfitzOP15mo ago
5e42a962-c3b7-4238-926e-ffa87df21892
Corfitz
CorfitzOP15mo ago
AH!!! It doesn't even add to the volume..
No description
No description
Corfitz
CorfitzOP15mo ago
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);
}
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;
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;
Brody
Brody15mo ago
fixed
sara!khan
sara!khan11mo ago
hi sir can i ask one thing what that value you put to 'VOLUME_PATH' ? is it just path in our localpath or ubuntupath sir ?
Want results from more Discord servers?
Add your server