I am currently working on a Facebook app, and I need to do the following: Create a hash containing "key", "user" and "link" fields. The link field should contain a string, that is the address of a json file.
Now, my problem is the following: I gather data from facebook and store it in the json file. How create a file DIRECLTY on heroku, somehow like a folder, when an event is dispatched (for example the user clicks on a button), and put the URL into the hash on the link field? My location should probably look like .../[user]/myfile.json
Or, if not heroku, can you please suggest another host where I can do the same thing?
Note: I am just getting started with databases, I have only very basic knowledge of SQL, and the database is not done yet. I don't know anything about postgres, but I can learn, if it is preferred. My app is mainly developed with php.
As @hakre said, Heroku runs apps on an Ephemeral filesystem. This means your local storage will be lost when the instance restarts.
Depending on the data you want to be storing, there are several options to store it.
TEXT
field.MondoDB
and CouchDB
store data as JSON documents. Both have plenty of features. Writing and reading are elementary operations on both. If you need a version history, CouchDB
does that for you (it stores all revisions of the JSON by default.There are plenty of other ways of storing your JSON documents on places other than a file. These are just the tip of the iceberg.
To create a file directly on heroku, you need to create the file in your source-tree and then it will be stored on heroku when you publish the application.
Naturally this does not work for files you want to create while your application runs. Heroku does not support creating files on runtime on the same server. At least not in a way that they will stay there because the file-system is not persistent (for anything that is not part of the source-tree).
You need to create these "files" in the database or in another remote locations like Amazon S3.
See as well: