doumaoao0182 2013-03-13 06:40
浏览 82
已采纳

在heroku上托管文件

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.

  • 写回答

2条回答 默认 最新

  • dpsq8476 2013-03-13 13:44
    关注

    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.

    1. Cookie: Send it back in a cookie and let the browser take care of it. This is viable if the data is created by the user and it expires at some point.
    2. PostgreSQL: If you are using an SQL database in your application, it could go there. Either as a deserialized row or a TEXT field.
    3. CDN: If the data is to be public to all, you could upload it to for example Amazon S3 or Rackspace CloudFiles and publish the container. Then you can refer to it by URL.
    4. Cloud storage: If the data needs some access control, you can still upload it to S3 or CloudFiles and pull it from there programmatically when it is requested. If there is a performance issue, you could cache it in Memcache or some of the other cache addons.
    5. Document database: 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.
    6. Browser local storage: You can store data on the browser now that we have HTML5. It is a bit bleeding edge and will not work on some of the older browsers still around.

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?