javascript接入阿里云服务器
2024-10-19 06:20:17
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)
})
最新文章
- tensorflow中的基本概念
- 【Python实战】Scrapy豌豆荚应用市场爬虫
- 浅析python 中__name__ = &#39;__main__&#39; 的作用
- Compounding绑定属性
- Swift的排序算法总结
- scroll滚动条插件初始化问题
- onclientclick和onclick区别
- Docker-创建一个mysql容器,并保存为本地镜像
- ajax 跨域解决 网上资料
- Java EE的十三种核心技术
- HTML5画布(变形)
- 【Android Developers Training】 82. 序言:传输数据时减少对电池寿命的影响
- 腾讯 AlloyCrop 1.0 发布
- RLP
- POJ_1064 二分搜索
- php归档格式:phar文件详解(创建、使用、解包还原提取)
- vscode/webstorm快捷键
- linux中ping IP可以通但是主机名不通
- Java的map键值对的用法,map的遍历,Entry对象的使用
- Python2.7-heapq
热门文章
- 自动化上传图片,路径driver.find_element_by_id(";oper-img-change";).send_keys(";C:\\Users\\76776\\Pictures\\logo.jpg";),为正确姿势,单\报错 &#39;unicodeescape&#39; codec can&#39;t decode bytes in position XXX: trun
- js自定义对象 (转)
- ios网络 -- HTTP请求 and 文件下载/断点下载
- java基础_02
- redux超易学三篇之一(单独说redux)
- 欧拉图 欧拉回路 欧拉通路 Euler的认识 (转)
- HOW TO MAKE IT FLOW ?
- Oracle9i之xmltype应用(2)
- linux的运行模式
- shell的常用脚本一