search

Home  >  Q&A  >  body text

文件上传 - 关于七牛使用python上传文件之后文件名的问题

import qiniu.conf

qiniu.conf.ACCESS_KEY = "ooooooooo"
qiniu.conf.SECRET_KEY = "xxxxxxxx"

import qiniu.rs
import qiniu.io
policy = qiniu.rs.PutPolicy("lylinuxbackup")
uptoken = policy.token()

localfile = 'wordpress.sql' 
policy = qiniu.rs.PutPolicy('xxxxxxxx') 
uptoken = policy.token()
data=open('wordpress1.sql')
ret, err = qiniu.io.put(uptoken, None, data)
print "ok!"

上面是代码 我上传到是本地的文件 文件名为wordpress1.sql
可是上传成功之后文件名变成类似于FtkZRfk8tTQAYJMb0MyIlrsBlod_
请问可否上传之后保存为原文件名?

PHP中文网PHP中文网2788 days ago860

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-04-17 13:04:29

    Reference http://developer.qiniu.com/docs/v6/sdk/python-sdk.html#upload-do
    The second parameter cannot be None, just fill in the original file name.

    reply
    0
  • Cancelreply