Hi,
I need to create temporary files in the /public folder.
Why? I need to generate small static .html snippets to avoid to call database every time when user refresh the page.
I made this code:
Meteor.startup(() => {
if (Meteor.isServer) {
const fs = require('fs');
Meteor.methods({
generateFile() {
const fileName = 'denis.txt';
let datapath = process.env.PWD + '/public/files/' + fileName;
if (Meteor.settings.environment === 'production') {
let meteorRoot = fs.realpathSync( process.cwd() + '/../' );
let publicPath = meteorRoot + '/web.browser/app/files/';
datapath = publicPath + fileName;
}
fs.writeFile(datapath, 'JUST SIMPLE TEXT',
function (err) {
if (err) {
throw err;
}
console.log('Done!');
}
);
}
});
}
});
So I created a forlder in /public/files.
On localhost it woks perfect. I can access the file like http://localhost:4000/files/denis.txt
On Galaxy hosting I see that it works and I get ‘Done!’ response in the log.
But when I try to get in touch the file like www.mysite.com/files/denis.txt It cannot be found there.
Any ideas how to solve it? Thanks!