Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Meteor private folder path in Meteor Deploy Environment

I need to get the path of the file inside the private folder. On my local machine I was able to get it by using the path "../../../../../", however, when I deployed to meteor server using meteor deploy, it doesn't work anymore. Also I tried to log the current directory using process.cwd() and got the following, which is different from the structure I got on my local machine:

/meteor/containers/3906c248-566e-61b7-4637-6fb724a33c16/bundle/programs/server

The directory logged from my local machine gives:

/Users/machineName/Documents/projectName/.meteor/local/build/programs/server

Note: I am using this path to setup https://www.npmjs.com/package/apn

like image 463
harinsa Avatar asked Mar 07 '26 14:03

harinsa


2 Answers

You can use assets/app/ as the relative path. While this may not make sense on the first look Meteor re-arranges your /private directory to map to assets/app from the /programs/server directory. This is both in development and production.

Basically assume that private/ maps to assets/app/.

like image 127
Tarang Avatar answered Mar 10 '26 06:03

Tarang


Call Assets.absoluteFilePath(assetPath) on one of the assets in the private folder, then chop of the name of the asset file from the string you get back, e.g., assuming you have a file called test.txt in the private folder:

var aFile = 'test.txt';// test.txt is in private folder
var aFilePath = Assets.absoluteFilePath(aFile);
var aFolder =  aFilePath.substr(0, aFilePath.length - aFile.length);
console.log(aFolder);

https://docs.meteor.com/api/assets.html#Assets-absoluteFilePath

like image 26
yeeking Avatar answered Mar 10 '26 06:03

yeeking



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!