Baidu found a lot of methods, said are not very clear, so I think IT is necessary for me to do a process remarks, the next time they do not Baidu, do not say, say more tired ~

npm i ali-oss -S
Copy the code

Install ali – oss

Then of course you can upload it to main.js, but I tried ~ it didn’t work, so I’ll just have to add it to the page where I need it

import OSS from "ali-oss";
Copy the code

Here’s the thing: The backend will give you an interface request, and the interface will return you the following data:

But here’s what really makes a difference:

The code:

That.$api.getStSosSparams (params, tha.token). Then ((r) => {showLoading = true; var ossfile = r.data; var client = new OSS({ region: "oss", accessKeyId: ossfile.accessKeyId, accessKeySecret: ossfile.accessKeySecret, stsToken: ossfile.securityToken, bucket: ossfile.bucketName, endpoint: ossfile.endpoint, }); client .multipartUpload(ossfile.ossPath, Fileslit [I]).then(function (result) {console.log(" success ", result); fileslit[I]).then(function (result) {console.log(" success ", result); }). Catch (function (err) {console.log(" failed to upload ", err); });Copy the code

I don’t know why every time my code block ends up as a line of code……..

I had to stickers……..