Skip to content

Commit

Permalink
feat: change uploadFile
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Apr 9, 2024
1 parent 6c6816f commit e65affd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions libs/zhi-blog-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# zhi-blog-api

## 1.66.0

### Minor Changes

- feat: change uploadFile

## 1.65.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-blog-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-blog-api",
"version": "1.65.0",
"version": "1.66.0",
"type": "module",
"description": "a common blog interface",
"main": "./dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions libs/zhi-blog-api/src/lib/IWebApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { IBlogApi } from "./IBlogApi"
import Post from "./models/post"
import ElectronCookie from "./models/ElectronCookie"
import WebConfig from "./WebConfig"
import MediaObject from "./models/mediaObject"

/**
* 通用博客接口
Expand Down Expand Up @@ -79,11 +80,10 @@ interface IWebApi extends IBlogApi {
/**
* 上传图片:调用平台 API 上传图片
*
* @param file 图片文件
* @param filename 文件名,可选
* @param mediaObject
* @returns Promise<string> 上传后的图片地址
*/
uploadFile(file: File, filename?: string): Promise<any>
uploadFile(mediaObject: MediaObject): Promise<any>

/**
* 更新文章:调用平台 API 更新文章(发布工具内部通过该接口替换文章内图片地址)
Expand Down
5 changes: 3 additions & 2 deletions libs/zhi-blog-api/src/lib/webAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { simpleLogger } from "zhi-lib-base"
import ElectronCookie from "./models/ElectronCookie"
import WebConfig from "./WebConfig"
import WebApi from "./webApi"
import MediaObject from "./models/mediaObject";

/**
* 网页授权核心基类
Expand Down Expand Up @@ -81,8 +82,8 @@ class WebAdaptor extends BlogAdaptor {
return await this.webAdaptor.addPost(post)
}

public async uploadFile(file: File, filename?: string): Promise<any> {
return await this.webAdaptor.uploadFile(file, filename)
public async uploadFile(mediaObject: MediaObject): Promise<any> {
return await this.webAdaptor.uploadFile(mediaObject)
}

public async editPost(postid: string, post: Post, publish?: boolean): Promise<boolean> {
Expand Down
3 changes: 2 additions & 1 deletion libs/zhi-blog-api/src/lib/webApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { NotImplementedException } from "zhi-lib-base"
import ElectronCookie from "./models/ElectronCookie"
import WebConfig from "./WebConfig"
import BlogApi from "./blogApi"
import MediaObject from "./models/mediaObject";

/**
* 网页授权基类
Expand All @@ -54,7 +55,7 @@ class WebApi extends BlogApi implements IWebApi {
throw new NotImplementedException("You must implement addPost in sub class")
}

public async uploadFile(file: File, filename?: string): Promise<any> {
public async uploadFile(mediaObject: MediaObject): Promise<any> {
throw new NotImplementedException("You must implement uploadFile in sub class")
}

Expand Down
7 changes: 7 additions & 0 deletions libs/zhi-siyuan-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# zhi-siyuan-api

## 2.20.10

### Patch Changes

- Updated dependencies
- zhi-blog-api@1.66.0

## 2.20.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-siyuan-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-siyuan-api",
"version": "2.20.9",
"version": "2.20.10",
"type": "module",
"description": "a siyuan-note api including both kernel and client",
"main": "./dist/index.js",
Expand Down

0 comments on commit e65affd

Please sign in to comment.