Accessing static files in meteor


#1

How to access files in meteor. I have problems in getting the path work in windows local machine and also when I deploy to meteor.com.

My files are located in .uploads/template/ folder inside my meteor app

I tried to use process.env.PWD but this come as undefined in windows,

Then I decided to get the path with
var base = process.cwd();
console.log(“base path:”, base);
var afterresolvefind = base.split(’.meteor’)[0];
var path = Meteor.npmRequire(‘path’);
var inputpath = ".uploads//templates//input.docx"
filepath = path.join(afterresolvefind, inputpath);

this works perfectly in windows local machine, but the folder organisation in meteor deployed in different.

If I use process.env.PWD it just gives “/” so I am not able to access the directory and the files in both places with same code.


#2

The Meteor way to access your files for reading is putting them in the private folder and accessing them with assets http://docs.meteor.com/#/full/assets_getText


#3

I don’t think the client can access files in the private folder.


#4

Since he was refering to process.cwd and npm.require, i thought he meant server side…


#5

I am doing it in server


#6

In my process I am also saving some pictures that users upload to the .uploads that I have created and I need to refer them as well. So I think in that case if I use the private folder and upload the pictures the server may restart.(I am assuming), but I dont want this to happen. What is the right way of handling this?