소스 검색

fix(api): Rename FormPart `value` to `file` to match docs and endpoint (#4307)

Fabian-Lars 3 년 전
부모
커밋
55f89d5f9d
3개의 변경된 파일10개의 추가작업 그리고 5개의 파일을 삭제
  1. 5 0
      .changes/api-fix-form-body.md
  2. 0 0
      core/tauri/scripts/bundle.js
  3. 5 5
      tooling/api/src/http.ts

+ 5 - 0
.changes/api-fix-form-body.md

@@ -0,0 +1,5 @@
+---
+"api": patch
+---
+
+Fix `FilePart` usage in `http.Body.form` by renaming the `value` property to `file`.

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
core/tauri/scripts/bundle.js


+ 5 - 5
tooling/api/src/http.ts

@@ -62,7 +62,7 @@ enum ResponseType {
 }
 
 interface FilePart<T> {
-  value: string | T
+  file: string | T
   mime?: string
   fileName?: string
 }
@@ -96,7 +96,7 @@ class Body {
    * Body.form({
    *   key: 'value',
    *   image: {
-   *     file: '/path/to/file', // either a path of an array buffer of the file contents
+   *     file: '/path/to/file', // either a path or an array buffer of the file contents
    *     mime: 'image/jpeg', // optional
    *     fileName: 'image.jpg' // optional
    *   }
@@ -117,10 +117,10 @@ class Body {
         r = v
       } else if (v instanceof Uint8Array || Array.isArray(v)) {
         r = Array.from(v)
-      } else if (typeof v.value === 'string') {
-        r = { value: v.value, mime: v.mime, fileName: v.fileName }
+      } else if (typeof v.file === 'string') {
+        r = { file: v.file, mime: v.mime, fileName: v.fileName }
       } else {
-        r = { value: Array.from(v.value), mime: v.mime, fileName: v.fileName }
+        r = { file: Array.from(v.file), mime: v.mime, fileName: v.fileName }
       }
       // eslint-disable-next-line security/detect-object-injection
       form[key] = r

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.