七牛上传图片的问题

如果我一个页面、有两个地方上传图片但是我想他们的key不同,要怎么才能分开不冲突呢,我现在的做法是创建两个文件

var uploader1= Qiniu.uploader({
'Key': function(up, file) {
            var now = new Date();
            var date = now.getFullYear()+((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1)+(now.getDate()<10?"0":"")+now.getDate();
            return "topic/cover/"+date;
        },
})
var uploader2= Qiniu.uploader({
    'Key': function(up, file) {
            var now = new Date();
            var date = now.getFullYear()+((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1)+(now.getDate()<10?"0":"")+now.getDate();
            return "topic/banner/"+date;
        },
    })
})

但是这样做为什么key会相同呢

阅读 2.4k
2 个回答

知道了,原来需要实例化

var Qiniu1 = new QiniuJsSDK()
var Qiniu2 = new QiniuJsSDK()
var uploader1= Qiniu1 .uploader({})
var uploader2= Qiniu2 .uploader({})

key不同是指?

推荐问题
logo
七牛云问答
子站问答
访问
宣传栏