1.建立一个js文件夹,然后倒入到vue文件中
2.
UploadLayer(file:any){
// console.log(file,‘file’)
var that =this
//@ts-ignore
let putOne =async (file:any)=> {
try {
//object-name可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形式,实现将文件上传至当前Bucket或Bucket下的指定目录。
let date = new Date()
let year = date.getFullYear().toString()
let mouth = (date.getMonth() + 1).toString()
let day = date.getDate().toString()
let hour = date.getHours().toString()
let min = date.getMinutes().toString()
let seconds = date.getSeconds().toString()
let tmpArr = year + mouth + day + hour + min + seconds + file.file.name
let result =await client.put(‘paofu2.0/self-support/’ +tmpArr, file.file)
// console.log(result);
if(result.res.status==200){
let imgurl = client.signatureUrl(‘paofu2.0/self-support/’ + tmpArr, {
expires: 315360000,
})
that.aOnlyReturnArray.push({imageId:null,propertyImage:imgurl})
that.
m
e
s
s
a
g
e
(
s
h
o
w
C
l
o
s
e
:
t
r
u
e
,
m
e
s
s
a
g
e
:
′
上
传
成
功
′
,
t
y
p
e
:
′
s
u
c
c
e
s
s
′
)
;
/
/
@
t
s
−
i
g
n
o
r
e
t
h
a
t
.
message({ showClose: true, message: '上传成功', type: 'success' }); //@ts-ignore that.
message(showClose:true,message:′上传成功′,type:′success′);//@ts−ignorethat.refs.uploadd.clearFiles()
}
} catch (e) {
console.log(e);
that.$message(‘上传错误’)
}
}
putOne(file);
}
阿里云oss上传单张,另外一篇博客是多张
最新推荐文章于 2023-08-11 10:00:18 发布