dongwuzun4630 2011-04-21 22:29
浏览 46
已采纳

按日期在服务器 - 子文件夹上存储大量文件?

I want to separate images stored on server in multiple folders. I'm thinking to create this structure /images/year/month (images/2011/04). Files names are stored in the database and also create date. Is this a good idea for separate files?

  • 写回答

2条回答 默认 最新

  • dongtangu8403 2011-04-21 22:39
    关注

    Well, it depends, in part, in what you want to do with them, and what you consider to be a large number.

    As with indexing columns in a database, this scheme may benefit some operations and be detrimental to others.

    For example, in a simple scheme that didn't have th date available, being able to find an image based on part of its name could end up being a little more difficult since you would have no idea where it would be. I've used this scheme for things like log files but that works well since I already knew where it will be:

    /logs/2011/01/2011_01_14.log
    

    and didn't have to go searching for it.

    Now you've solved that particular problem since your database entry holds the date as well so I can't see any immediate problems with your scheme. That's not to say there isn't any :-)

    My advice would be to do the simplest thing (flat directory format) initially and only worry about it when it becomes a problem. Since you have the dates, it would be a simple matter to move all images, based on that, to separate directories.

    Of course, if you've already implemented separate directories, stick with that. Again, it should hopefully be relatively easy to adjust in future if the method is flawed.

    One thing you may want to consider is storing the location (absolute, or relative to a known point) in the database as well, rather than just the date. Then you would use that (rather than an operation on the date) to locate the file.

    This would allow you to totally change the method used for placing files without having to change any of the code that located them.

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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器