mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
feat: update file api
This commit is contained in:
parent
2648c03b97
commit
36dfd1ae02
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-md",
|
"name": "vue-md",
|
||||||
"version": "1.4.6",
|
"version": "1.4.7",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-md",
|
"name": "vue-md",
|
||||||
"version": "1.4.6",
|
"version": "1.4.7",
|
||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"description": "An open-source wechat markdown editor.",
|
"description": "An open-source wechat markdown editor.",
|
||||||
"author": "doocs",
|
"author": "doocs",
|
||||||
|
@ -161,7 +161,6 @@ async function aliOSSFileUpload(content, filename) {
|
|||||||
path,
|
path,
|
||||||
} = JSON.parse(localStorage.getItem("aliOSSConfig"));
|
} = JSON.parse(localStorage.getItem("aliOSSConfig"));
|
||||||
const buffer = Buffer(content, "base64");
|
const buffer = Buffer(content, "base64");
|
||||||
try {
|
|
||||||
const dir = `${path}/${dateFilename}`;
|
const dir = `${path}/${dateFilename}`;
|
||||||
const client = new OSS({
|
const client = new OSS({
|
||||||
region,
|
region,
|
||||||
@ -169,10 +168,10 @@ async function aliOSSFileUpload(content, filename) {
|
|||||||
accessKeyId,
|
accessKeyId,
|
||||||
accessKeySecret,
|
accessKeySecret,
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
const res = await client.put(dir, buffer);
|
const res = await client.put(dir, buffer);
|
||||||
return cdnHost == ""
|
if (cdnHost == "") return res.url;
|
||||||
? res.url
|
return `${cdnHost}/${path == "" ? dateFilename : dir}`;
|
||||||
: `${cdnHost}/${path == "" ? dateFilename : dir}`;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e);
|
return Promise.reject(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user