提交 6cb91628 编写于 作者: 雪洛's avatar 雪洛

feat: add uniCloud storage api

上级 8bed2a9b
...@@ -667,13 +667,13 @@ ...@@ -667,13 +667,13 @@
} }
}, },
{ {
"path": "pages/API/call-function/call-function", "path": "pages/API/unicloud-call-function/unicloud-call-function",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
}, },
{ {
"path": "pages/API/import-object/import-object", "path": "pages/API/unicloud-import-object/unicloud-import-object",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
...@@ -891,6 +891,15 @@ ...@@ -891,6 +891,15 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
} }
,{
"path" : "pages/API/unicloud-file-api/unicloud-file-api",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
], ],
"globalStyle": { "globalStyle": {
"pageOrientation": "portrait", "pageOrientation": "portrait",
......
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt">
<button type="primary" @click="uploadFile">选择文件上传</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: '云存储'
}
},
onLoad() {
},
onUnload() {
},
methods: {
uploadFile: function () {
uni.chooseImage({
count: 1,
success(res) : void {
uni.showLoading({
title: '上传中...'
})
const tempFilePath = res.tempFilePaths[0]
uniCloud.uploadFile({
filePath: tempFilePath,
cloudPath: 'test.jpg'
})
.then<void>(function (res) {
uni.hideLoading()
console.log(res)
uni.showModal({
content: '上传成功',
showCancel: false
});
})
.catch<void>(function (err : any | null) {
uni.hideLoading()
const error = err as UniCloudError
uni.showModal({
content: '上传失败,' + error.errMsg,
showCancel: false
});
})
// .finally((_: number) : void => {
// uni.hideLoading()
// })
},
fail(err) : void {
console.error('chooseImage fail: ', err)
}
})
}
}
}
</script>
<style>
</style>
...@@ -380,11 +380,15 @@ ...@@ -380,11 +380,15 @@
pages: [ pages: [
{ {
name: '云函数', name: '云函数',
url: 'call-function', url: 'unicloud-call-function',
}, },
{ {
name: '云对象', name: '云对象',
url: 'import-object', url: 'unicloud-import-object',
},
{
name: '云存储',
url: 'unicloud-file-api',
}, },
] as Page[], ] as Page[],
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册