Skip to content

Commit 55f89d5

Browse files
authored
fix(api): Rename FormPart value to file to match docs and endpoint (#4307)
1 parent 69ae6f1 commit 55f89d5

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

.changes/api-fix-form-body.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"api": patch
3+
---
4+
5+
Fix `FilePart` usage in `http.Body.form` by renaming the `value` property to `file`.

core/tauri/scripts/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/api/src/http.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ enum ResponseType {
6262
}
6363

6464
interface FilePart<T> {
65-
value: string | T
65+
file: string | T
6666
mime?: string
6767
fileName?: string
6868
}
@@ -96,7 +96,7 @@ class Body {
9696
* Body.form({
9797
* key: 'value',
9898
* image: {
99-
* file: '/path/to/file', // either a path of an array buffer of the file contents
99+
* file: '/path/to/file', // either a path or an array buffer of the file contents
100100
* mime: 'image/jpeg', // optional
101101
* fileName: 'image.jpg' // optional
102102
* }
@@ -117,10 +117,10 @@ class Body {
117117
r = v
118118
} else if (v instanceof Uint8Array || Array.isArray(v)) {
119119
r = Array.from(v)
120-
} else if (typeof v.value === 'string') {
121-
r = { value: v.value, mime: v.mime, fileName: v.fileName }
120+
} else if (typeof v.file === 'string') {
121+
r = { file: v.file, mime: v.mime, fileName: v.fileName }
122122
} else {
123-
r = { value: Array.from(v.value), mime: v.mime, fileName: v.fileName }
123+
r = { file: Array.from(v.file), mime: v.mime, fileName: v.fileName }
124124
}
125125
// eslint-disable-next-line security/detect-object-injection
126126
form[key] = r

0 commit comments

Comments
 (0)