Skip to Content

creating files using node.js in cloud foundry

Hi,

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({});router.post('/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); } 
console.log(buffer); 
console.log(name); 
res.send(name); });
});

is there any way to store these files pertinently.

regards.

pratheek.

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

    https://help.sap.com/viewer/2ee77ef7ea4648f9ab2c54ee3aef0a29/Cloud/en-US/84eb69a421294ba0a407579490413dfa.html?q=%22object%20store%20service%22

    -Andrew

    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
    Gregor

    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.