Question

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.

Was it helpful?

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.

OTHER TIPS

Filesystem in most cloud solutions are "ephemeral", so you can not use FS. You will have to use solutions like S3/ DB for such purpose

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top