Skip to content

Commit

Permalink
feat: remove try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
fish.yu committed Apr 18, 2024
1 parent eec5735 commit 30c5585
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lib/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,17 @@ class Downloader {
}

async uploadImageFromUrl(url) {
try {
// 获取图片后缀
const pathname = new URL(url).pathname;
const suffix = '.' + pathname.split('.').pop();
// 下载图片
const content = await downloadImage(url);
const imageName = crypto.randomUUID() + suffix;
const imageUrl = `_images/${imageName}`;
// 上传到github
const result = await this.gh.writeFile(imageUrl, content, { encode: false });
console.log('uploadImageFromUrl success:', result);
return `https://github.com/${imageUrl}`;
} catch (error) {
console.error('uploadImageFromUrl Error:', error);
}
// 获取图片后缀
const pathname = new URL(url).pathname;
const suffix = '.' + pathname.split('.').pop();
// 下载图片
const content = await downloadImage(url);
const imageName = crypto.randomUUID() + suffix;
const imageUrl = `_images/${imageName}`;
// 上传到github
const result = await this.gh.writeFile(imageUrl, content, { encode: false });
console.log('uploadImageFromUrl success:', result);
return `https://github.com/${imageUrl}`;
}

/**
Expand Down

0 comments on commit 30c5585

Please sign in to comment.