更新版本至 0.0.40,新增 getState 方法以获取文件状态,并扩展 Stat 类型以包含更多元数据

This commit is contained in:
2026-02-01 17:43:00 +08:00
parent 78f781ef39
commit 17d00ca08f
2 changed files with 27 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@kevisual/api",
"version": "0.0.39",
"version": "0.0.40",
"description": "",
"main": "mod.ts",
"scripts": {

View File

@@ -156,6 +156,18 @@ export class QueryResources {
return { code: 200, message: '上传成功' };
}
async getState(filepath: string, opts?: DataOpts): Promise<Result<Stat>> {
const url = `${this.prefix}${filepath}`;
return adapter({
url,
params: {
stat: '1',
},
method: 'GET' as any,
headers: this.header(opts?.headers),
});
}
async createFolder(folderpath: string, opts?: DataOpts): Promise<Result<any>> {
const filepath = folderpath.endsWith('/') ? `${folderpath}keep.txt` : `${folderpath}/keep.txt`;
return this.uploadFile(filepath, '文件夹占位,其他文件不存在,文件夹不存在,如果有其他文件夹,删除当前文件夹占位文件即可', opts);
@@ -252,3 +264,17 @@ export const getContentType = (filename: string): string => {
return type;
};
type Stat = {
"standardHeaders": any,
"size": string,
"etag": string,
"lastModified": string,
"metaData": {
"app-source": string,
"cache-control": string,
"content-type": string,
"share"?: string
},
"versionId": null
}