V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
wikinee
V2EX  ›  问与答

关于云存储分享同名的问题

  •  
  •   wikinee · 2015-08-12 14:56:18 +08:00 · 1522 次点击
    这是一个创建于 3201 天前的主题,其中的信息可能已经有所发展或是发生改变。
    像腾讯,百度他们,如果分享文件就算是同名,只要目录不同就行。这些是怎么做到的啊?目前只能做到MD5命名,不知道他们是怎么完成的?
    5 条回复    2015-08-12 16:39:06 +08:00
    kslr
        1
    kslr  
       2015-08-12 15:08:52 +08:00
    七牛那边文件名就是 "/dir/1.jpg"。
    wikinee
        2
    wikinee  
    OP
       2015-08-12 15:11:42 +08:00
    @kslr 对啊,如果多人分享文件重名了,覆盖了怎么办。。。肯定要找个唯一标识啊
    kslr
        3
    kslr  
       2015-08-12 15:38:53 +08:00   ❤️ 1
    @wikinee 你指的是多人的同名文件重叠吗? username+path映射就可以。
    wikinee
        4
    wikinee  
    OP
       2015-08-12 16:34:02 +08:00
    @kslr <a href=“xxxsss” download=“下载文件.txt”>file1</a>(html5)
    囧,html5新特性download属性,暂时这样搞了,剩下的就是xxxsss唯一标识符的事情了
    kslr
        5
    kslr  
       2015-08-12 16:39:06 +08:00
    @wikinee 这。。。 你是要做用户上传文件的东西?

    上传到upload文件夹命名就用username+time+type或者各种能够分辨的就行
    下载的时候指定header就可以
    php伪代码
    ···php
    header('Content-type: application/pdf');
    header('Content-Disposition: attachment; filename="name.pdf"');
    readfile("$filename");
    exit();
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1135 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 23:14 · PVG 07:14 · LAX 16:14 · JFK 19:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.