search

Home  >  Q&A  >  body text

javascript - Problem with Qiniu uploading pictures

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?

迷茫迷茫2715 days ago662

reply all(2)I'll reply

  • 欧阳克

    欧阳克2017-06-22 11:56:16

    What do you mean by different keys?

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-22 11:56:16

    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({})

    reply
    0
  • Cancelreply