authInfo = r.data.authInfo[0]//后台请求的
var client = new OSS({
region: 'oss-cn-beijing',// 云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,部署在服务端使用RAM子账号或STS,部署在客户端使用STS。
accessKeyId: authInfo.sts.secretId,
accessKeySecret: authInfo.sts.secretKey,
bucket: authInfo.bucket,
stsToken: authInfo.sts.token,
endpoint: 'http://oss-cn-beijing.aliyuncs.com'
})
var time = new Date().getTime()
co(function * () {
var result = yield client.multipartUpload('/martrix/web/message/' + time + '/' + f.name, f, {
progress: function * (p) {
console.log('Progress: ' + p)
ar type = 49
var name = f.name || f.type.replace('/', '.')
switch (name.split('.').pop()) {
case 'mp4':
type = 43
break
case 'gif':
type = 47
break
case 'jpg':
case 'bmp':
case 'png':
case 'tif':
type = 3
break
default:
type = 49
break
}
var url = 'http://mv.**.com' + '/martrix/web/message/' + time + '/' + encodeURI(f.name)//图片的路径
if (p == 1) {
if (f.size < 0 || type != 49) {
that.sendMsg(type, url)
} else {
that.sendMsg(1, '分享文件:\n' + f.name + '\n长按下一条可复制网址')
that.sendMsg(1, url)
}
}
},
meta: {
year: 2018,
people: 'test'
}
})
console.log(result)
var head = yield client.head(f.name)
console.log(head)
}).catch(function (err) {
console.log(err)
})

  

最新文章

  1. tensorflow中的基本概念
  2. 【Python实战】Scrapy豌豆荚应用市场爬虫
  3. 浅析python 中__name__ = &#39;__main__&#39; 的作用
  4. Compounding绑定属性
  5. Swift的排序算法总结
  6. scroll滚动条插件初始化问题
  7. onclientclick和onclick区别
  8. Docker-创建一个mysql容器,并保存为本地镜像
  9. ajax 跨域解决 网上资料
  10. Java EE的十三种核心技术
  11. HTML5画布(变形)
  12. 【Android Developers Training】 82. 序言:传输数据时减少对电池寿命的影响
  13. 腾讯 AlloyCrop 1.0 发布
  14. RLP
  15. POJ_1064 二分搜索
  16. php归档格式:phar文件详解(创建、使用、解包还原提取)
  17. vscode/webstorm快捷键
  18. linux中ping IP可以通但是主机名不通
  19. Java的map键值对的用法,map的遍历,Entry对象的使用
  20. Python2.7-heapq

热门文章

  1. 自动化上传图片,路径driver.find_element_by_id(&quot;oper-img-change&quot;).send_keys(&quot;C:\\Users\\76776\\Pictures\\logo.jpg&quot;),为正确姿势,单\报错 &#39;unicodeescape&#39; codec can&#39;t decode bytes in position XXX: trun
  2. js自定义对象 (转)
  3. ios网络 -- HTTP请求 and 文件下载/断点下载
  4. java基础_02
  5. redux超易学三篇之一(单独说redux)
  6. 欧拉图 欧拉回路 欧拉通路 Euler的认识 (转)
  7. HOW TO MAKE IT FLOW ?
  8. Oracle9i之xmltype应用(2)
  9. linux的运行模式
  10. shell的常用脚本一