dongshengheng1013 2011-02-14 04:53
浏览 39
已采纳

我应该把所有这些上传的文件放在哪里?

I'm building a webapp that as a small subset of one of the features allows images to be uploaded. I'm running a lamp stack, with Mongo instead of MySql.

I use a javascript uploader with a php backend to upload the files. The whole framework is under version control though, so I don't want to dump these files anywhere inside my framework, as it would get messy with the version control, and sub-optimal when I eventually migrate the media over to a CDN.

So, my question is - On a VPS, where should I drop these images for now? In some folder external to my framework? In my DB as bson? I've heard Mongo does a decent job handling binary data...

And, as a follow up, if I'm eventually planning on moving the content over to a CDN, how would you recommend structuring my schema for now?

My current plan would be something like the following:

  1. All uploads are named with a unique ID and dropped in an external folder, defined by a globally accessible variable of sorts.

  2. A reference to each images' name is stored in the db.

Is there anything obviously stupid about going about it that way, possibly causing me a scaling headache later?

Here's a summarized specific question, just so this is a little more of an SO friendly question:

Given a Linux, Apache, Mongo, PHP Framework on a VPS, what is the best way to store uploaded images while keeping scalability and speed as the 2 most important factors in deciding on the solution?

  • 写回答

2条回答 默认 最新

  • 普通网友 2011-02-14 05:54
    关注

    if your plan is moving to CDN, the answer couldn't be more easy: create a subdomain on your VPS, and drop your images there, and you will have decent CDN simulation as well as reliable file storage.

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

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法