javascript - 七牛上传图片的问题
问题描述
如果我一个页面、有两个地方上传图片但是我想他们的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会相同呢
问题解答
回答1:key不同是指?
回答2:知道了,原来需要实例化
var Qiniu1 = new QiniuJsSDK()var Qiniu2 = new QiniuJsSDK()var uploader1= Qiniu1 .uploader({})var uploader2= Qiniu2 .uploader({})
相关文章:
1. linux - 编译时提示头文件#include <mysql/mysql.h>不存在,百度之后也没解决2. JAVA 版本问题?3. java - Spring +Mybatis 事务 不能回滚4. node.js - webpack --watch以后报错env: node: No such file or directory5. javascript - nodejs的列表不能往中间插入数据吗?6. css3 - 如何出現橫向捲軸?7. javascript - immutable配合react提升性能?8. java - yuicompressor-maven-plugin 合并可用却不压缩, 哪配置不对?9. html页面中怎么将两个点之间的距离用直线连接起来?10. node.js - 微信小程序有自己的ws协议,用nodejs的话,还需要nginx干嘛呢
