业务场景:实时获取经纬度,记录坐标到一个文件当中,最后上传该文件(不需要用户手动选取文件上传)
async upload() {
let filePath = `_doc/dirName/${this.id}.json`;
let info = { id: this.id };
uni.uploadFile({
url: '',
files: [{
name: 'key',
uri: filePath,
}],
formData: info,
header: { "Authorization":uni.getStorageSync('token') },
method: 'POST'
})
},