@amityco/ts-sdk-react-native 7.22.1-2614119.0 → 7.22.1-c05e1197.0

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.
@@ -13,5 +13,5 @@
13
13
  * @category File API
14
14
  * @async
15
15
  */
16
- export declare const uploadAudio: (formData: FormData, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'audio'>[]>>;
16
+ export declare const uploadAudio: (inputFormData: FormData, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'audio'>[]>>;
17
17
  //# sourceMappingURL=uploadAudio.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadAudio.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadAudio.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,0BACK,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAqC7C,CAAC"}
1
+ {"version":3,"file":"uploadAudio.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadAudio.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,kBACP,QAAQ,0BACA,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAsC7C,CAAC"}
@@ -13,5 +13,5 @@
13
13
  * @category File API
14
14
  * @async
15
15
  */
16
- export declare const uploadClip: (formData: FormData, feedType?: Amity.ContentFeedType, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'clip'>[]>>;
16
+ export declare const uploadClip: (inputFormData: FormData, feedType?: Amity.ContentFeedType, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'clip'>[]>>;
17
17
  //# sourceMappingURL=uploadClip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadClip.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadClip.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,aACX,QAAQ,aACP,MAAM,eAAe,0BACT,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CA2C5C,CAAC"}
1
+ {"version":3,"file":"uploadClip.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadClip.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,kBACN,QAAQ,aACZ,MAAM,eAAe,0BACT,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAyC5C,CAAC"}
@@ -13,5 +13,5 @@
13
13
  * @category File API
14
14
  * @async
15
15
  */
16
- export declare const uploadFile: <T extends Amity.FileType = any>(formData: FormData, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File[]>>;
16
+ export declare const uploadFile: <T extends Amity.FileType = any>(inputFormData: FormData, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File[]>>;
17
17
  //# sourceMappingURL=uploadFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadFile.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,6CACX,QAAQ,0BACK,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAmCpC,CAAC"}
1
+ {"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadFile.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,kDACN,QAAQ,0BACA,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAiCpC,CAAC"}
@@ -14,5 +14,5 @@
14
14
  * @category File API
15
15
  * @async
16
16
  */
17
- export declare const uploadImage: (formData: FormData, onProgress?: ((percent: number) => void) | undefined, altText?: string) => Promise<Amity.Cached<Amity.File<'image'>[]>>;
17
+ export declare const uploadImage: (inputFormData: FormData, onProgress?: ((percent: number) => void) | undefined, altText?: string) => Promise<Amity.Cached<Amity.File<'image'>[]>>;
18
18
  //# sourceMappingURL=uploadImage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadImage.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadImage.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,WAAW,aACZ,QAAQ,0BACK,MAAM,KAAK,IAAI,yBAC5B,MAAM,KACf,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAuD7C,CAAC"}
1
+ {"version":3,"file":"uploadImage.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadImage.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,WAAW,kBACP,QAAQ,0BACA,MAAM,KAAK,IAAI,yBAC5B,MAAM,KACf,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAsD7C,CAAC"}
@@ -14,5 +14,5 @@
14
14
  * @category File API
15
15
  * @async
16
16
  */
17
- export declare const uploadVideo: (formData: FormData, feedType?: Amity.ContentFeedType, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'video'>[]>>;
17
+ export declare const uploadVideo: (inputFormData: FormData, feedType?: Amity.ContentFeedType, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'video'>[]>>;
18
18
  //# sourceMappingURL=uploadVideo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadVideo.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadVideo.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,aACP,MAAM,eAAe,0BACT,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CA2C7C,CAAC"}
1
+ {"version":3,"file":"uploadVideo.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadVideo.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,kBACP,QAAQ,aACZ,MAAM,eAAe,0BACT,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAyC7C,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { AxiosRequestConfig } from 'axios';
2
+ /**
3
+ * Builds the axios request config for multipart file uploads.
4
+ *
5
+ * ## Why this exists (React Native 0.83 New Architecture)
6
+ *
7
+ * Previously every upload hardcoded `{ 'content-type': 'multipart/form-data' }`.
8
+ * That header has **no `boundary`**, which breaks multipart uploads on React
9
+ * Native's New Architecture (Bridgeless): the request body is sent without the
10
+ * file bytes (it surfaces as `[object Object]` / `Stream Closed` /
11
+ * `AxiosError: Network Error`, or the server replies `400 "No files uploaded."`).
12
+ *
13
+ * The correct behaviour for the React Native / browser environment is to let
14
+ * the platform networking layer (XMLHttpRequest) serialize the `FormData` and
15
+ * generate the `multipart/form-data; boundary=…` header itself. So we must NOT
16
+ * set the content-type at all in that environment.
17
+ *
18
+ * We also pin `adapter: 'xhr'` so axios always routes the request through React
19
+ * Native's `XMLHttpRequest` (which understands RN file parts), rather than
20
+ * auto-selecting the `fetch` adapter that the New Architecture now also exposes.
21
+ *
22
+ * On Node (the `form-data` package exposes `getHeaders()`), we keep using its
23
+ * generated headers — which already include the correct boundary — and leave
24
+ * the adapter selection to axios (its http adapter, via the configured agents).
25
+ *
26
+ * @param formData The multipart payload about to be uploaded.
27
+ * @returns A partial axios config to spread into the upload request.
28
+ *
29
+ * @category File Util
30
+ * @hidden
31
+ */
32
+ export declare const getUploadRequestConfig: (formData: FormData) => AxiosRequestConfig;
33
+ //# sourceMappingURL=getUploadRequestConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUploadRequestConfig.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/utils/getUploadRequestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,sBAAsB,aAAc,QAAQ,KAAG,kBA0B3D,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Rebuilds a multipart `FormData` inside the SDK's own module realm.
3
+ *
4
+ * ## Why this is required (React Native 0.83 New Architecture)
5
+ *
6
+ * When the app/UIKit constructs `new FormData()` from a *different* module realm
7
+ * than the SDK (which happens with `.tgz`/duplicate-`react-native` setups, and
8
+ * is common under the New Architecture), the resulting instance is NOT an
9
+ * `instanceof` the `FormData` that the SDK's axios — and React Native's native
10
+ * `XMLHttpRequest` — reference.
11
+ *
12
+ * As a result `axios.isFormData()` returns `false`, so axios:
13
+ * - serializes the body as a plain object → it goes out as `"[object Object]"`, and
14
+ * - applies its default POST content-type (`application/x-www-form-urlencoded`),
15
+ * which the upload server rejects with
16
+ * `"multipart != application/x-www-form-urlencoded"`.
17
+ *
18
+ * Re-creating the FormData here, with the SDK's own `new FormData()`, produces an
19
+ * instance both axios and RN's XHR recognize, so the file is sent as a real
20
+ * multipart body.
21
+ *
22
+ * We also backfill the file part's MIME `type` (via the file name/URI) because
23
+ * React Native on Android does not set it by default, and the backend rejects
24
+ * file parts without a content type.
25
+ *
26
+ * Only React Native's `FormData` exposes `getParts()`. For Node's `form-data`
27
+ * package or a spec-compliant `FormData`, there is nothing to normalize and the
28
+ * original instance is returned unchanged.
29
+ *
30
+ * @param formData The FormData passed in by the caller.
31
+ * @returns A FormData safe to hand to the upload transport.
32
+ *
33
+ * @category File Util
34
+ * @hidden
35
+ */
36
+ export declare const recreateUploadFormData: (formData: FormData) => FormData;
37
+ //# sourceMappingURL=recreateUploadFormData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recreateUploadFormData.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/utils/recreateUploadFormData.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,sBAAsB,aAAc,QAAQ,KAAG,QAoC3D,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -12,6 +12,7 @@ var uuid$1 = require('react-native-uuid');
12
12
  var jwtDecode = require('jwt-decode');
13
13
  var reactNative = require('react-native');
14
14
  var hash = require('object-hash');
15
+ var mime = require('mime');
15
16
  var Hls = require('hls.js');
16
17
 
17
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -42,6 +43,7 @@ var AsyncStorage__default = /*#__PURE__*/_interopDefaultLegacy(AsyncStorage);
42
43
  var uuid__default = /*#__PURE__*/_interopDefaultLegacy(uuid$1);
43
44
  var jwtDecode__default = /*#__PURE__*/_interopDefaultLegacy(jwtDecode);
44
45
  var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
46
+ var mime__default = /*#__PURE__*/_interopDefaultLegacy(mime);
45
47
  var Hls__default = /*#__PURE__*/_interopDefaultLegacy(Hls);
46
48
 
47
49
  exports.MembershipAcceptanceTypeEnum = void 0;
@@ -16862,6 +16864,129 @@ getFile.locally = (fileId) => {
16862
16864
  };
16863
16865
  };
16864
16866
 
16867
+ /**
16868
+ * Builds the axios request config for multipart file uploads.
16869
+ *
16870
+ * ## Why this exists (React Native 0.83 New Architecture)
16871
+ *
16872
+ * Previously every upload hardcoded `{ 'content-type': 'multipart/form-data' }`.
16873
+ * That header has **no `boundary`**, which breaks multipart uploads on React
16874
+ * Native's New Architecture (Bridgeless): the request body is sent without the
16875
+ * file bytes (it surfaces as `[object Object]` / `Stream Closed` /
16876
+ * `AxiosError: Network Error`, or the server replies `400 "No files uploaded."`).
16877
+ *
16878
+ * The correct behaviour for the React Native / browser environment is to let
16879
+ * the platform networking layer (XMLHttpRequest) serialize the `FormData` and
16880
+ * generate the `multipart/form-data; boundary=…` header itself. So we must NOT
16881
+ * set the content-type at all in that environment.
16882
+ *
16883
+ * We also pin `adapter: 'xhr'` so axios always routes the request through React
16884
+ * Native's `XMLHttpRequest` (which understands RN file parts), rather than
16885
+ * auto-selecting the `fetch` adapter that the New Architecture now also exposes.
16886
+ *
16887
+ * On Node (the `form-data` package exposes `getHeaders()`), we keep using its
16888
+ * generated headers — which already include the correct boundary — and leave
16889
+ * the adapter selection to axios (its http adapter, via the configured agents).
16890
+ *
16891
+ * @param formData The multipart payload about to be uploaded.
16892
+ * @returns A partial axios config to spread into the upload request.
16893
+ *
16894
+ * @category File Util
16895
+ * @hidden
16896
+ */
16897
+ const getUploadRequestConfig = (formData) => {
16898
+ // Node `form-data` instances expose getHeaders() (with a valid boundary).
16899
+ if ('getHeaders' in formData) {
16900
+ return { headers: formData.getHeaders() };
16901
+ }
16902
+ // React Native / browser.
16903
+ //
16904
+ // Set `multipart/form-data` explicitly. We must NOT omit it: when omitted,
16905
+ // axios applies its default POST content-type (`application/x-www-form-urlencoded`)
16906
+ // and the server rejects the upload (`multipart != application/x-www-form-urlencoded`).
16907
+ // React Native's native networking layer appends the real `boundary=…` to this
16908
+ // header when it serializes a (recognized) FormData body.
16909
+ //
16910
+ // `adapter: 'xhr'` pins axios to React Native's XMLHttpRequest (which
16911
+ // understands RN file parts) instead of the `fetch` adapter the New
16912
+ // Architecture also exposes.
16913
+ //
16914
+ // NOTE: this only works if the FormData instance is recognized as multipart.
16915
+ // See `recreateUploadFormData` — the upload APIs rebuild the FormData in the
16916
+ // SDK's own module realm first, otherwise axios/XHR treat it as a plain object
16917
+ // and send `[object Object]`.
16918
+ return {
16919
+ headers: { 'content-type': 'multipart/form-data' },
16920
+ adapter: 'xhr',
16921
+ };
16922
+ };
16923
+
16924
+ /**
16925
+ * Rebuilds a multipart `FormData` inside the SDK's own module realm.
16926
+ *
16927
+ * ## Why this is required (React Native 0.83 New Architecture)
16928
+ *
16929
+ * When the app/UIKit constructs `new FormData()` from a *different* module realm
16930
+ * than the SDK (which happens with `.tgz`/duplicate-`react-native` setups, and
16931
+ * is common under the New Architecture), the resulting instance is NOT an
16932
+ * `instanceof` the `FormData` that the SDK's axios — and React Native's native
16933
+ * `XMLHttpRequest` — reference.
16934
+ *
16935
+ * As a result `axios.isFormData()` returns `false`, so axios:
16936
+ * - serializes the body as a plain object → it goes out as `"[object Object]"`, and
16937
+ * - applies its default POST content-type (`application/x-www-form-urlencoded`),
16938
+ * which the upload server rejects with
16939
+ * `"multipart != application/x-www-form-urlencoded"`.
16940
+ *
16941
+ * Re-creating the FormData here, with the SDK's own `new FormData()`, produces an
16942
+ * instance both axios and RN's XHR recognize, so the file is sent as a real
16943
+ * multipart body.
16944
+ *
16945
+ * We also backfill the file part's MIME `type` (via the file name/URI) because
16946
+ * React Native on Android does not set it by default, and the backend rejects
16947
+ * file parts without a content type.
16948
+ *
16949
+ * Only React Native's `FormData` exposes `getParts()`. For Node's `form-data`
16950
+ * package or a spec-compliant `FormData`, there is nothing to normalize and the
16951
+ * original instance is returned unchanged.
16952
+ *
16953
+ * @param formData The FormData passed in by the caller.
16954
+ * @returns A FormData safe to hand to the upload transport.
16955
+ *
16956
+ * @category File Util
16957
+ * @hidden
16958
+ */
16959
+ const recreateUploadFormData = (formData) => {
16960
+ const source = formData;
16961
+ if (typeof source.getParts !== 'function') {
16962
+ return formData;
16963
+ }
16964
+ const rebuilt = new FormData();
16965
+ source.getParts().forEach(part => {
16966
+ var _a;
16967
+ const { fieldName } = part;
16968
+ // String fields (accessType, preferredFilename, feedType, altText, …).
16969
+ if (typeof part.string === 'string') {
16970
+ rebuilt.append(fieldName, part.string);
16971
+ return;
16972
+ }
16973
+ // File parts are represented as `{ uri, name?, type? }` in React Native.
16974
+ if (part.uri) {
16975
+ const type = part.type ||
16976
+ ((_a = part.headers) === null || _a === void 0 ? void 0 : _a['content-type']) ||
16977
+ (part.name && mime__default["default"].getType(part.name)) ||
16978
+ mime__default["default"].getType(part.uri) ||
16979
+ undefined;
16980
+ rebuilt.append(fieldName, {
16981
+ uri: part.uri,
16982
+ name: part.name,
16983
+ type,
16984
+ });
16985
+ }
16986
+ });
16987
+ return rebuilt;
16988
+ };
16989
+
16865
16990
  /* begin_public_function
16866
16991
  id: file.upload.file
16867
16992
  */
@@ -16880,8 +17005,10 @@ getFile.locally = (fileId) => {
16880
17005
  * @category File API
16881
17006
  * @async
16882
17007
  */
16883
- const uploadFile = async (formData, onProgress) => {
17008
+ const uploadFile = async (inputFormData, onProgress) => {
16884
17009
  const client = getActiveClient();
17010
+ // Rebuild in the SDK's realm so axios/XHR serialize it as real multipart.
17011
+ const formData = recreateUploadFormData(inputFormData);
16885
17012
  client.log('file/uploadFile', formData);
16886
17013
  const files = formData.getAll('files');
16887
17014
  if (!files.length)
@@ -16889,15 +17016,9 @@ const uploadFile = async (formData, onProgress) => {
16889
17016
  const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
16890
17017
  formData.append('accessType', accessType);
16891
17018
  formData.append('preferredFilename', files[0].name);
16892
- const headers = 'getHeaders' in formData
16893
- ? formData.getHeaders()
16894
- : { 'content-type': 'multipart/form-data' };
16895
- const { data } = await client.upload.post('/api/v4/files', formData, {
16896
- headers,
16897
- onUploadProgress({ loaded, total = 100 }) {
17019
+ const { data } = await client.upload.post('/api/v4/files', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
16898
17020
  onProgress && onProgress(Math.round((loaded * 100) / total));
16899
- },
16900
- });
17021
+ } }));
16901
17022
  // API-FIX: payload should be serialized properly
16902
17023
  // const { files } = data
16903
17024
  const cachedAt = client.cache && Date.now();
@@ -16967,8 +17088,10 @@ const fileUrlWithSize = (fileUrl, size) => {
16967
17088
  * @category File API
16968
17089
  * @async
16969
17090
  */
16970
- const uploadVideo = async (formData, feedType, onProgress) => {
17091
+ const uploadVideo = async (inputFormData, feedType, onProgress) => {
16971
17092
  const client = getActiveClient();
17093
+ // Rebuild in the SDK's realm so axios/XHR serialize it as real multipart.
17094
+ const formData = recreateUploadFormData(inputFormData);
16972
17095
  client.log('file/uploadVideo', formData);
16973
17096
  const files = formData.getAll('files');
16974
17097
  if (!files.length)
@@ -16979,15 +17102,9 @@ const uploadVideo = async (formData, feedType, onProgress) => {
16979
17102
  if (feedType) {
16980
17103
  formData.append('feedType', feedType);
16981
17104
  }
16982
- const headers = 'getHeaders' in formData
16983
- ? formData.getHeaders()
16984
- : { 'content-type': 'multipart/form-data' };
16985
- const { data } = await client.upload.post('/api/v4/videos', formData, {
16986
- headers,
16987
- onUploadProgress({ loaded, total = 100 }) {
17105
+ const { data } = await client.upload.post('/api/v4/videos', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
16988
17106
  onProgress && onProgress(Math.round((loaded * 100) / total));
16989
- },
16990
- });
17107
+ } }));
16991
17108
  // API-FIX: payload should be serialized properly
16992
17109
  // const { files } = data
16993
17110
  const cachedAt = client.cache && Date.now();
@@ -17019,8 +17136,11 @@ const uploadVideo = async (formData, feedType, onProgress) => {
17019
17136
  * @category File API
17020
17137
  * @async
17021
17138
  */
17022
- const uploadImage = async (formData, onProgress, altText) => {
17139
+ const uploadImage = async (inputFormData, onProgress, altText) => {
17023
17140
  const client = getActiveClient();
17141
+ // Rebuild the FormData in the SDK's realm so axios/XHR serialize it as real
17142
+ // multipart (otherwise it is sent as "[object Object]"). See helper for details.
17143
+ const formData = recreateUploadFormData(inputFormData);
17024
17144
  client.log('file/uploadImage', formData);
17025
17145
  const files = formData.getAll('files');
17026
17146
  if (files === null || files === void 0 ? void 0 : files.length) {
@@ -17040,15 +17160,9 @@ const uploadImage = async (formData, onProgress, altText) => {
17040
17160
  }
17041
17161
  const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
17042
17162
  formData.append('accessType', accessType);
17043
- const headers = 'getHeaders' in formData
17044
- ? formData.getHeaders()
17045
- : { 'content-type': 'multipart/form-data' };
17046
- const { data } = await client.upload.post('/api/v4/images', formData, {
17047
- headers,
17048
- onUploadProgress({ loaded, total = 100 }) {
17163
+ const { data } = await client.upload.post('/api/v4/images', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
17049
17164
  onProgress && onProgress(Math.round((loaded * 100) / total));
17050
- },
17051
- });
17165
+ } }));
17052
17166
  // API-FIX: payload should be serialized properly
17053
17167
  // const { files } = data
17054
17168
  const cachedAt = client.cache && Date.now();
@@ -17110,8 +17224,10 @@ const updateAltText = async (fileId, altText) => {
17110
17224
  * @category File API
17111
17225
  * @async
17112
17226
  */
17113
- const uploadClip = async (formData, feedType, onProgress) => {
17227
+ const uploadClip = async (inputFormData, feedType, onProgress) => {
17114
17228
  const client = getActiveClient();
17229
+ // Rebuild in the SDK's realm so axios/XHR serialize it as real multipart.
17230
+ const formData = recreateUploadFormData(inputFormData);
17115
17231
  client.log('file/uploadClip', formData);
17116
17232
  const file = formData.get('files');
17117
17233
  if (!file)
@@ -17122,15 +17238,9 @@ const uploadClip = async (formData, feedType, onProgress) => {
17122
17238
  if (feedType) {
17123
17239
  formData.append('feedType', feedType);
17124
17240
  }
17125
- const headers = 'getHeaders' in formData
17126
- ? formData.getHeaders()
17127
- : { 'content-type': 'multipart/form-data' };
17128
- const { data } = await client.upload.post('/api/v4/clips', formData, {
17129
- headers,
17130
- onUploadProgress({ loaded, total = 100 }) {
17241
+ const { data } = await client.upload.post('/api/v4/clips', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
17131
17242
  onProgress && onProgress(Math.round((loaded * 100) / total));
17132
- },
17133
- });
17243
+ } }));
17134
17244
  // API-FIX: payload should be serialized properly
17135
17245
  // const { files } = data
17136
17246
  const cachedAt = client.cache && Date.now();
@@ -17161,8 +17271,10 @@ const uploadClip = async (formData, feedType, onProgress) => {
17161
17271
  * @category File API
17162
17272
  * @async
17163
17273
  */
17164
- const uploadAudio = async (formData, onProgress) => {
17274
+ const uploadAudio = async (inputFormData, onProgress) => {
17165
17275
  const client = getActiveClient();
17276
+ // Rebuild in the SDK's realm so axios/XHR serialize it as real multipart.
17277
+ const formData = recreateUploadFormData(inputFormData);
17166
17278
  client.log('file/uploadAudio', formData);
17167
17279
  const files = formData.getAll('file');
17168
17280
  if (files.length === 0)
@@ -17171,13 +17283,9 @@ const uploadAudio = async (formData, onProgress) => {
17171
17283
  const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
17172
17284
  formData.append('accessType', accessType);
17173
17285
  formData.append('preferredFilename', file.name);
17174
- const headers = { 'content-type': 'multipart/form-data' };
17175
- const { data } = await client.upload.post('/api/v4/audios', formData, {
17176
- headers,
17177
- onUploadProgress({ loaded, total = 100 }) {
17286
+ const { data } = await client.upload.post('/api/v4/audios', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
17178
17287
  onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.round((loaded * 100) / total));
17179
- },
17180
- });
17288
+ } }));
17181
17289
  const cachedAt = client.cache && Date.now();
17182
17290
  if (client.cache)
17183
17291
  ingestInCache({ files: data }, { cachedAt });