Skip to Content

creating files using node.js in cloud foundry


im using multer to upload file to the disk.

the problem here is whenever service instance in cockpit is stopped or restarted, all the files gets wiped.

const upload2=multer({});'/uploadfile',upload2.single('file'),(req,res)=>{
let name=req.file.originalname;
let buffer=req.file.buffer; 
fs.writeFile(name, buffer, function (err) { 
if (err) { return res.send(err); } 
res.send(name); });

is there any way to store these files pertinently.



Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Aug 04, 2020 at 03:10 PM

    If your need are similar to storing static documents, you might want to check out the object store service.

    cf m -s objectstore


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 04, 2020 at 05:56 AM

    Hi Pratheek,

    welcome to the cloud world. You must see the service instance as disposable. You need to store your files in a persistence. The expensive solution is HANA. You find an example using CAP here: media-handling. More affordable is to use S3 Buckets as in this example: cap-media-node.

    Best regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.