Skip to content

Commit 36dfd1a

Browse files
committed
feat: update file api
1 parent 2648c03 commit 36dfd1a

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-md",
3-
"version": "1.4.6",
3+
"version": "1.4.7",
44
"homepage": ".",
55
"description": "An open-source wechat markdown editor.",
66
"author": "doocs",

src/api/file.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,17 @@ async function aliOSSFileUpload(content, filename) {
161161
path,
162162
} = JSON.parse(localStorage.getItem("aliOSSConfig"));
163163
const buffer = Buffer(content, "base64");
164+
const dir = `${path}/${dateFilename}`;
165+
const client = new OSS({
166+
region,
167+
bucket,
168+
accessKeyId,
169+
accessKeySecret,
170+
});
164171
try {
165-
const dir = `${path}/${dateFilename}`;
166-
const client = new OSS({
167-
region,
168-
bucket,
169-
accessKeyId,
170-
accessKeySecret,
171-
});
172172
const res = await client.put(dir, buffer);
173-
return cdnHost == ""
174-
? res.url
175-
: `${cdnHost}/${path == "" ? dateFilename : dir}`;
173+
if (cdnHost == "") return res.url;
174+
return `${cdnHost}/${path == "" ? dateFilename : dir}`;
176175
} catch (e) {
177176
return Promise.reject(e);
178177
}

0 commit comments

Comments
 (0)