代码
// oss 上传阿里云
axios({
url: 需要访问的OSS域名,格式为BucketName.Endpoint,
method: 'get',
data: file.file,
headers: { 'Content-Type': 'multipart/form-data' }
}).then(res => {
const filename = 'xxx',
const targetDir = res.data.data.dir
const oss = new OSS({
isServerSignature: true,
policyBase64: res.data.data.policy,
signature: res.data.data.signature,
accessKeyId: res.data.data.accessid,
host: res.data.data.host
});
oss.upload(file.file, filename, targetDir).then(res => {
// 上传成功后的返回的东西
console.log(res)
})
});