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
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/
.
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