dff-util 1.0.3 → 1.0.4

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.
@@ -23,6 +23,6 @@ export declare class Http {
23
23
  static Put(url: string, data: any, headers: any, type?: RespType): Promise<any>;
24
24
  static Delete(url: string, params: any, headers: any, type?: RespType): Promise<any>;
25
25
  static Token(sessionInfo: any, appKey: string, apiKey?: string, type?: RespType): Promise<any>;
26
- static Upload(fullUrl: string, file: File, isHeadersAddMultiForm?: boolean, data?: Record<string, any>, headers?: any, type?: RespType): Promise<any>;
27
- static Download(fullUrl: string, params: any, headers?: any): Promise<Buffer>;
26
+ static Upload(fullUrl: string, file: File, isHeadersAddMultiForm?: boolean, data?: Record<string, any>, headers?: any, method?: 'POST' | 'PUT', type?: RespType): Promise<any>;
27
+ static Download(fullUrl: string, params: any, headers?: any, method?: string): Promise<Buffer>;
28
28
  }
package/dist/main/http.js CHANGED
@@ -127,7 +127,7 @@ class Http {
127
127
  });
128
128
  }
129
129
  static Upload(fullUrl_1, file_1) {
130
- return __awaiter(this, arguments, void 0, function* (fullUrl, file, isHeadersAddMultiForm = false, data = {}, headers = exports.BaseHeaders, type = RespType.JSON) {
130
+ return __awaiter(this, arguments, void 0, function* (fullUrl, file, isHeadersAddMultiForm = false, data = {}, headers = exports.BaseHeaders, method = 'PUT', type = RespType.JSON) {
131
131
  const formData = new FormData();
132
132
  console.log(file);
133
133
  formData.append('file', file);
@@ -141,7 +141,7 @@ class Http {
141
141
  }
142
142
  try {
143
143
  const requestOptions = {
144
- method: 'POST',
144
+ method: method,
145
145
  body: formData,
146
146
  headers: Object.assign({}, headers),
147
147
  };
@@ -156,10 +156,10 @@ class Http {
156
156
  });
157
157
  }
158
158
  static Download(fullUrl_1, params_1) {
159
- return __awaiter(this, arguments, void 0, function* (fullUrl, params, headers = exports.HttpHeaders) {
159
+ return __awaiter(this, arguments, void 0, function* (fullUrl, params, headers = exports.HttpHeaders, method = 'GET') {
160
160
  fullUrl = params ? `${fullUrl}?${new URLSearchParams(params).toString()}` : fullUrl;
161
161
  try {
162
- const requestOptions = { method: 'GET', headers: headers || exports.HttpHeaders };
162
+ const requestOptions = { method: method, headers: headers || exports.HttpHeaders };
163
163
  const response = yield fetch(fullUrl, requestOptions);
164
164
  const blob = yield response.blob();
165
165
  const buffer = Buffer.from(yield blob.arrayBuffer());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dff-util",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {