Skip to content

Commit

Permalink
Merge pull request #417 from terwer/dev
Browse files Browse the repository at this point in the history
fix: clipboard upload not work for external picgo
  • Loading branch information
terwer committed Apr 23, 2024
2 parents 0a0d8ff + b80eb2b commit 572a934
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
4 changes: 0 additions & 4 deletions libs/Universal-PicGo-Core/src/core/ExternalPicgo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ class ExternalPicgo {
input = newInput
}

if (input?.length === 0) {
throw new Error(`cannot not find valid image`)
}

this.requestUrl = this.db.get("extPicgoApiUrl") ?? this.requestUrl
let ret: IImgInfo[] = []

Expand Down
4 changes: 2 additions & 2 deletions libs/Universal-PicGo-Core/src/plugins/uploader/aliyun/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const handleNode = async (ctx: IPicGo): Promise<IPicGo> => {
})

const imgList = ctx.output
const customUrl = aliYunOptions.customUrl
const path = aliYunOptions.path
const customUrl = aliYunOptions.customUrl || ""
const path = aliYunOptions.path || ""

for (const img of imgList) {
if (img.fileName) {
Expand Down
4 changes: 2 additions & 2 deletions libs/Universal-PicGo-Core/src/plugins/uploader/aliyun/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const handleWeb = async (ctx: IPicGo): Promise<IPicGo> => {
}

const imgList = ctx.output
const customUrl = aliYunOptions.customUrl
const path = aliYunOptions.path
const customUrl = aliYunOptions.customUrl || ""
const path = aliYunOptions.path || ""
for (const img of imgList) {
if (img.fileName) {
let image = img.buffer
Expand Down
4 changes: 2 additions & 2 deletions libs/Universal-PicGo-Core/src/plugins/uploader/awss3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const handle = async (ctx: IPicGo): Promise<IPicGo> => {
client,
index: idx,
bucketName: userConfig.bucketName,
path: formatPath(item, userConfig.uploadPath),
path: formatPath(item, userConfig.uploadPath || ""),
item: item,
acl: userConfig.acl || "public-read",
customUrl: userConfig.customUrl,
customUrl: userConfig.customUrl || "",
corsProxy: userConfig.corsProxy,
})
)
Expand Down
10 changes: 7 additions & 3 deletions libs/Universal-PicGo-Core/src/plugins/uploader/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import mime from "mime-types"
import { ILocalesKey } from "../../i18n/zh-CN"
import { bufferToBase64 } from "../../utils/common"
import { IBuildInEvent } from "../../utils/enums"
import { browserPathJoin } from "../../utils/browserUtils"

const postOptions = (fileName: string, options: IGithubConfig, data: any): AxiosRequestConfig => {
const path = options.path || ""
Expand Down Expand Up @@ -66,9 +67,12 @@ const handle = async (ctx: IPicGo): Promise<IPicGo> => {
delete img.base64Image
delete img.buffer
if (githubOptions.customUrl) {
img.imgUrl = `${githubOptions.customUrl}/${encodeURI(githubOptions.path)}${encodeURIComponent(
img.fileName
)}`
let imgUrl = githubOptions.customUrl
if (githubOptions.path) {
imgUrl = browserPathJoin(imgUrl, encodeURI(githubOptions.path))
}
imgUrl = browserPathJoin(imgUrl, encodeURIComponent(img.fileName))
img.imgUrl = imgUrl
} else {
img.imgUrl = body.content.download_url
}
Expand Down
3 changes: 2 additions & 1 deletion libs/Universal-PicGo-Core/src/plugins/uploader/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const postOptions = (userConfig: IGitlabConfig, base64Image: string, fileName: s
}

const repo = encodeURIComponent(userConfig.repo)
const filepath = encodeURIComponent(userConfig.path + fileName)
const userPath = userConfig.path || ""
const filepath = encodeURIComponent(userPath + fileName)
return {
method: "POST",
url: `${userConfig.url}/api/v4/projects/${repo}/repository/files/${filepath}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const handle = async (ctx: IPicGo): Promise<IPicGo> => {
delete img.base64Image
delete img.buffer
const baseUrl = qiniuOptions.url
const options = qiniuOptions.options
const options = qiniuOptions.options || ""
img.imgUrl = browserPathJoin(baseUrl, body.key, options)
} else {
ctx.emit(IBuildInEvent.NOTIFICATION, {
Expand Down
2 changes: 1 addition & 1 deletion libs/Universal-PicGo-Core/src/plugins/uploader/tcyun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const postOptions = (
version: string
): AxiosRequestConfig => {
const area = options.area
const path = options.path
const path = options.path || ""
if (!options.version || options.version === "v4") {
return {
method: "POST",
Expand Down

0 comments on commit 572a934

Please sign in to comment.