search

Home  >  Q&A  >  body text

java - 想用七牛做个小型网盘。有关于上传下载的问题不解!求教!

1.文件不能重名怎么办? 两个人都上传一个叫做 周报的文件。 不能都让覆盖了!应该都可以上传都可以用。

我使用的是JAVA端上传方式。 form表单提交我的服务器,然后我的服务器提交给七牛。
Response res2 = uploadManager.put(b, '文件名', getUpToken());

有什么方法可以让文件名不重复?

2.如果存储的文件名是不重复的字符串, 那么我下载的时候怎么可以让下载的文件是上传时候的名称。 当然我自己数据库中存的有上传时候的文件名。

还是我的思路不太对,有别的方法可以解决?

ringa_leeringa_lee2941 days ago342

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:36:24

    Do it this way. User 1 uploaded 1.txt, user 2 also uploaded 1.txt, and the background renamed 1.txt into a unique string. Save to /2016/03/30/17/njgfddsfhjjhv.txt, and the other one to /2016/03/30/17/njgjjjjjjjjjjjhv.txt. The database stores the relationship between the source file name, the named file name and the user. It’s ok.

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 17:36:24

    Different users correspond to different directories, and users can create directories under their own directories.

    reply
    0
  • Cancelreply