Cannot obtain full path to an api project folder

Hi everybody.

I have a Web Server created on render (NodeJS - Express) , in which I upload image files to a folder created by the api itself. This folder is created inside api/ project folder, and I need the full path of it. The thing is, when I use __dirname I get “/opt/render/project/src/api/folder”, which is a relative path and I use a base64 library that needs full path to the folder in which I pretend to save my image, but it is crashing right now.

How could I get the full path of this folder?

Thanks in advance for support.


/opt/render/project/src/api/folder is not a relative path, that’s a full path from the root of the filesystem on Linux.

As an aside, if you’re uploading files, you should be aware that instance filesystems are ephemeral. Meaning that anything written to the instance after they boot will be lost when it’s next restarted (e.g. next deploy, or spin-down if using a free instance type). If you want to persist files, you’ll need a Render Disk or other external store.


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