javascript - Problem with Qiniu uploading pictures
迷茫
迷茫 2017-06-22 11:54:16
0
2
658

If I upload images in two places on a page but I think their keys are different, how can I separate them without conflict? My current approach is to create two files

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;
        },
    })
})

But why will the keys be the same if we do this?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
学霸

What do you mean by different keys?

伊谢尔伦

I know, it turns out that it needs to be instantiated

var Qiniu1 = new QiniuJsSDK()
var Qiniu2 = new QiniuJsSDK()
var uploader1= Qiniu1 .uploader({})
var uploader2= Qiniu2 .uploader({})
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template