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,18 +161,17 @@ 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");
|
||||||
|
const dir = `${path}/${dateFilename}`;
|
||||||
|
const client = new OSS({
|
||||||
|
region,
|
||||||
|
bucket,
|
||||||
|
accessKeyId,
|
||||||
|
accessKeySecret,
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const dir = `${path}/${dateFilename}`;
|
|
||||||
const client = new OSS({
|
|
||||||
region,
|
|
||||||
bucket,
|
|
||||||
accessKeyId,
|
|
||||||
accessKeySecret,
|
|
||||||
});
|
|
||||||
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