wtfai 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/upload.d.ts CHANGED
@@ -35,4 +35,8 @@ export declare class UploadService {
35
35
  * 上传图片(自动压缩)
36
36
  */
37
37
  uploadImage(params: UploadImageParams): Promise<string>;
38
+ /**
39
+ * 获取文件签名 URL
40
+ */
41
+ getSignedUrl(key: string, bucketTypeCode?: 'public' | 'private'): Promise<string>;
38
42
  }
package/dist/upload.js CHANGED
@@ -157,6 +157,25 @@ class UploadService {
157
157
  ...rest
158
158
  });
159
159
  }
160
+ async getSignedUrl(key, bucketTypeCode = 'private') {
161
+ const searchParams = new URLSearchParams({
162
+ key,
163
+ bucketType: bucketTypeCode
164
+ });
165
+ const res = await fetch(`${this.baseUrl}/workflows/signed-url?${searchParams.toString()}`, {
166
+ method: 'GET',
167
+ headers: {
168
+ 'Content-Type': 'application/json',
169
+ ...this.headers
170
+ }
171
+ });
172
+ if (!res.ok) {
173
+ const error = await res.json().catch(()=>({}));
174
+ throw new Error(error.message || '获取签名 URL 失败');
175
+ }
176
+ const data = await res.json();
177
+ return data;
178
+ }
160
179
  constructor(baseUrl, headers = {}){
161
180
  _define_property(this, "baseUrl", void 0);
162
181
  _define_property(this, "headers", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wtfai",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {