The image upload by user during registration is not showing on the user dashboard

on my application, I use node multer to store the images on a folder called uploads inside public folder

and i create a disk with the path:/public/uploads

but the image is not showing on the user’s dashbaorad

this is how it is stored on database:
image:
http://foobank-api.onrender.com/public/uploads/app1.PNG-1702141113138.…

Hi there,

The public/uploads folder from your git repo isn’t the same location as your disk mounted at /public/uploads. Your git public/uploads full path will be /opt/render/project/src/public/uploads (the relative path from where your service executes is public/uploads). Your service will either need to access images from both locations or you need to merge these two locations. At runtime, any images a user of your service uploads should be written to your disk at /public/uploads. If you want to use a single location for uploads, it should be your disk. To merge the contents of public/uploads your disk you can run a rsync when your service boots by changing your start command to rsync -a public/uploads/ /public/uploads && node src/index.js

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

I am on windows

is this a right command

“scripts”: {
“start”: “rsync -a public/uploads/ /public/uploads && node src/index.js”
}
??

HI there,

That looks okay to me.

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

Your request (50297) has been updated. To add additional comments, reply to this email.

In your case an rsync wouldn’t be applicable. The start command runs on a new deploy, so any files uploaded would have been lost before that command gets to run, so you’re syncing an empty /opt/render/project/src/public/uploads with your disk /public/uploads

You need to update your code to be write the file uploads to the disk mount path /public/uploads

I have this response from support

Hi there,

Yes, it is correct that you should be writing any files uploaded to your disk during runtime.

The purpose of the rsync is to sync any files you commit to git and push to Render when you deploy your service. If you will never do this, then it isn’t needed. This means during runtime of your service, it only needs to use /public/uploads for reading and writing uploads.

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.