Search code examples
node.jshostingpaascloud-foundry

cloudfoundry: how to use filesystem


I am planning to use cloudfoundry paas service (from VMWare) for hosting my node.js application. I have seen that it has support for mongo and redis in the service layer and node.js framework. So far so good.

Now I need to store my mediafiles(images uploaded by users) to a filesystem. I have the metadata stored in Mongo.

I have been searching internet, but have not yet got good information.


Solution

  • You cannot do that for the following reasons:

    • There are multiple host machines running your application. They each have their own filesystems. Each running process in your application would see a different set of files.
    • The host machines on which your particular application is running can change moment-to-moment. Indeed, they will change every time you re-deploy your application. Every time a process is started on a new host machine, it will see an empty set of files. Every time a process is stopped on an old host machine, all the files would be permanently deleted.

    You absolutely must solve this problem in another way.

    • Store the media files in MongoDB GridFS.
    • Store the media files in an object store such as Amazon S3 or Rackspace Cloud Files.