I'm using Parse Server on Heroku and I'm wondering if I'm able to save files to heroku via cloud code.
Something like this:
Cloud code (main.js):
Parse.Cloud.define("saveFile", function(request, response) {
fs.writeFile("test", "helloworld", function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
}
then call this function via curl call in terminal:
curl -X POST -H "X-Parse-Application-Id: yourappid" -H “Content-Type: application/json" https://your-parse-server.herokuapp.com/parse/functions/saveFile
in heroku logs, I am able to see the console which prints "The file was saved", however, when I looked into the heroku /app directory (via heroku CLI: heroku run ls) the file "test" was not listed.
My questions:
Thanks in advance!
No, this is not possible. Heroku has an ephemeral filesystem.
Whenever you deploy your app, they build a container on which that version of your code can run. That container is then fetched and run as dynos.
If you write files to the disk, they will not be persisted outside the currently running container (any other dyno won't have them and they will be permanently lost when the app is restarted/deployed).
Any code change you wish to make to your application necessitates a new deployment.