feat: 更新版本至 0.0.63,升级依赖项并添加 setPrefix 和 getRelativePath 方法
This commit is contained in:
@@ -26,6 +26,10 @@ export class QueryResources {
|
||||
setUsername(username: string) {
|
||||
this.prefix = `/${username}/resources/`;
|
||||
}
|
||||
/**
|
||||
* 设置prefix,类似 /{username}/resources/;
|
||||
* @param prefix
|
||||
*/
|
||||
setPrefix(prefix: string) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
@@ -166,6 +170,17 @@ export class QueryResources {
|
||||
this.onProcess?.({ type: 'uploadFinish', filename, size: file.size, process: 100 });
|
||||
return { code: 200, message: '上传成功' };
|
||||
}
|
||||
/**
|
||||
* 移除 prefix,获取相对路径
|
||||
* @param filepath
|
||||
* @returns
|
||||
*/
|
||||
getRelativePath(filepath: string): string {
|
||||
if (filepath.startsWith(this.prefix)) {
|
||||
return filepath.slice(this.prefix.length);
|
||||
}
|
||||
return filepath;
|
||||
}
|
||||
|
||||
async getStat(filepath: string, opts?: DataOpts): Promise<Result<Stat>> {
|
||||
const url = `${this.prefix}${filepath}`;
|
||||
|
||||
Reference in New Issue
Block a user