@amityco/ts-sdk-react-native 7.22.0 → 7.22.1-8d7f6ee6.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.
- package/dist/fileRepository/api/uploadAudio.d.ts.map +1 -1
- package/dist/fileRepository/api/uploadClip.d.ts.map +1 -1
- package/dist/fileRepository/api/uploadFile.d.ts.map +1 -1
- package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
- package/dist/fileRepository/api/uploadVideo.d.ts.map +1 -1
- package/dist/fileRepository/utils/getUploadRequestConfig.d.ts +33 -0
- package/dist/fileRepository/utils/getUploadRequestConfig.d.ts.map +1 -0
- package/dist/index.cjs.js +55 -39
- package/dist/index.esm.js +55 -39
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadAudio.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadAudio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadAudio.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadAudio.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,0BACK,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAmC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadClip.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadClip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadClip.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadClip.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;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,CAsC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadFile.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,6CACX,QAAQ,0BACK,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CA8BpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadImage.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadImage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadImage.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadImage.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,WAAW,aACZ,QAAQ,0BACK,MAAM,KAAK,IAAI,yBAC5B,MAAM,KACf,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAkD7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadVideo.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadVideo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadVideo.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadVideo.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;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,CAsC7C,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,kBAa3D,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -13442,7 +13442,7 @@ const getWatchSessionStorage = () => {
|
|
|
13442
13442
|
return storageInstance;
|
|
13443
13443
|
};
|
|
13444
13444
|
|
|
13445
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
13445
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
13446
13446
|
/*
|
|
13447
13447
|
* The crypto algorithm used for importing key and signing string
|
|
13448
13448
|
*/
|
|
@@ -16862,6 +16862,50 @@ getFile.locally = (fileId) => {
|
|
|
16862
16862
|
};
|
|
16863
16863
|
};
|
|
16864
16864
|
|
|
16865
|
+
/**
|
|
16866
|
+
* Builds the axios request config for multipart file uploads.
|
|
16867
|
+
*
|
|
16868
|
+
* ## Why this exists (React Native 0.83 New Architecture)
|
|
16869
|
+
*
|
|
16870
|
+
* Previously every upload hardcoded `{ 'content-type': 'multipart/form-data' }`.
|
|
16871
|
+
* That header has **no `boundary`**, which breaks multipart uploads on React
|
|
16872
|
+
* Native's New Architecture (Bridgeless): the request body is sent without the
|
|
16873
|
+
* file bytes (it surfaces as `[object Object]` / `Stream Closed` /
|
|
16874
|
+
* `AxiosError: Network Error`, or the server replies `400 "No files uploaded."`).
|
|
16875
|
+
*
|
|
16876
|
+
* The correct behaviour for the React Native / browser environment is to let
|
|
16877
|
+
* the platform networking layer (XMLHttpRequest) serialize the `FormData` and
|
|
16878
|
+
* generate the `multipart/form-data; boundary=…` header itself. So we must NOT
|
|
16879
|
+
* set the content-type at all in that environment.
|
|
16880
|
+
*
|
|
16881
|
+
* We also pin `adapter: 'xhr'` so axios always routes the request through React
|
|
16882
|
+
* Native's `XMLHttpRequest` (which understands RN file parts), rather than
|
|
16883
|
+
* auto-selecting the `fetch` adapter that the New Architecture now also exposes.
|
|
16884
|
+
*
|
|
16885
|
+
* On Node (the `form-data` package exposes `getHeaders()`), we keep using its
|
|
16886
|
+
* generated headers — which already include the correct boundary — and leave
|
|
16887
|
+
* the adapter selection to axios (its http adapter, via the configured agents).
|
|
16888
|
+
*
|
|
16889
|
+
* @param formData The multipart payload about to be uploaded.
|
|
16890
|
+
* @returns A partial axios config to spread into the upload request.
|
|
16891
|
+
*
|
|
16892
|
+
* @category File Util
|
|
16893
|
+
* @hidden
|
|
16894
|
+
*/
|
|
16895
|
+
const getUploadRequestConfig = (formData) => {
|
|
16896
|
+
// Node `form-data` instances expose getHeaders() (with a valid boundary).
|
|
16897
|
+
if ('getHeaders' in formData) {
|
|
16898
|
+
return { headers: formData.getHeaders() };
|
|
16899
|
+
}
|
|
16900
|
+
// React Native / browser: let XMLHttpRequest build the multipart body and set
|
|
16901
|
+
// `multipart/form-data; boundary=…`. Passing `null` removes any inherited
|
|
16902
|
+
// content-type so axios does not force `application/json`.
|
|
16903
|
+
return {
|
|
16904
|
+
headers: { 'Content-Type': null },
|
|
16905
|
+
adapter: 'xhr',
|
|
16906
|
+
};
|
|
16907
|
+
};
|
|
16908
|
+
|
|
16865
16909
|
/* begin_public_function
|
|
16866
16910
|
id: file.upload.file
|
|
16867
16911
|
*/
|
|
@@ -16889,15 +16933,9 @@ const uploadFile = async (formData, onProgress) => {
|
|
|
16889
16933
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
16890
16934
|
formData.append('accessType', accessType);
|
|
16891
16935
|
formData.append('preferredFilename', files[0].name);
|
|
16892
|
-
const
|
|
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 }) {
|
|
16936
|
+
const { data } = await client.upload.post('/api/v4/files', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
16898
16937
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
16899
|
-
}
|
|
16900
|
-
});
|
|
16938
|
+
} }));
|
|
16901
16939
|
// API-FIX: payload should be serialized properly
|
|
16902
16940
|
// const { files } = data
|
|
16903
16941
|
const cachedAt = client.cache && Date.now();
|
|
@@ -16979,15 +17017,9 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
16979
17017
|
if (feedType) {
|
|
16980
17018
|
formData.append('feedType', feedType);
|
|
16981
17019
|
}
|
|
16982
|
-
const
|
|
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 }) {
|
|
17020
|
+
const { data } = await client.upload.post('/api/v4/videos', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
16988
17021
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
16989
|
-
}
|
|
16990
|
-
});
|
|
17022
|
+
} }));
|
|
16991
17023
|
// API-FIX: payload should be serialized properly
|
|
16992
17024
|
// const { files } = data
|
|
16993
17025
|
const cachedAt = client.cache && Date.now();
|
|
@@ -17040,15 +17072,9 @@ const uploadImage = async (formData, onProgress, altText) => {
|
|
|
17040
17072
|
}
|
|
17041
17073
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
17042
17074
|
formData.append('accessType', accessType);
|
|
17043
|
-
const
|
|
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 }) {
|
|
17075
|
+
const { data } = await client.upload.post('/api/v4/images', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
17049
17076
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
17050
|
-
}
|
|
17051
|
-
});
|
|
17077
|
+
} }));
|
|
17052
17078
|
// API-FIX: payload should be serialized properly
|
|
17053
17079
|
// const { files } = data
|
|
17054
17080
|
const cachedAt = client.cache && Date.now();
|
|
@@ -17122,15 +17148,9 @@ const uploadClip = async (formData, feedType, onProgress) => {
|
|
|
17122
17148
|
if (feedType) {
|
|
17123
17149
|
formData.append('feedType', feedType);
|
|
17124
17150
|
}
|
|
17125
|
-
const
|
|
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 }) {
|
|
17151
|
+
const { data } = await client.upload.post('/api/v4/clips', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
17131
17152
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
17132
|
-
}
|
|
17133
|
-
});
|
|
17153
|
+
} }));
|
|
17134
17154
|
// API-FIX: payload should be serialized properly
|
|
17135
17155
|
// const { files } = data
|
|
17136
17156
|
const cachedAt = client.cache && Date.now();
|
|
@@ -17171,13 +17191,9 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
17171
17191
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
17172
17192
|
formData.append('accessType', accessType);
|
|
17173
17193
|
formData.append('preferredFilename', file.name);
|
|
17174
|
-
const
|
|
17175
|
-
const { data } = await client.upload.post('/api/v4/audios', formData, {
|
|
17176
|
-
headers,
|
|
17177
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
17194
|
+
const { data } = await client.upload.post('/api/v4/audios', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
17178
17195
|
onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.round((loaded * 100) / total));
|
|
17179
|
-
}
|
|
17180
|
-
});
|
|
17196
|
+
} }));
|
|
17181
17197
|
const cachedAt = client.cache && Date.now();
|
|
17182
17198
|
if (client.cache)
|
|
17183
17199
|
ingestInCache({ files: data }, { cachedAt });
|
package/dist/index.esm.js
CHANGED
|
@@ -29515,7 +29515,7 @@ const getWatchSessionStorage = () => {
|
|
|
29515
29515
|
return storageInstance;
|
|
29516
29516
|
};
|
|
29517
29517
|
|
|
29518
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
29518
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
29519
29519
|
/*
|
|
29520
29520
|
* The crypto algorithm used for importing key and signing string
|
|
29521
29521
|
*/
|
|
@@ -32935,6 +32935,50 @@ getFile.locally = (fileId) => {
|
|
|
32935
32935
|
};
|
|
32936
32936
|
};
|
|
32937
32937
|
|
|
32938
|
+
/**
|
|
32939
|
+
* Builds the axios request config for multipart file uploads.
|
|
32940
|
+
*
|
|
32941
|
+
* ## Why this exists (React Native 0.83 New Architecture)
|
|
32942
|
+
*
|
|
32943
|
+
* Previously every upload hardcoded `{ 'content-type': 'multipart/form-data' }`.
|
|
32944
|
+
* That header has **no `boundary`**, which breaks multipart uploads on React
|
|
32945
|
+
* Native's New Architecture (Bridgeless): the request body is sent without the
|
|
32946
|
+
* file bytes (it surfaces as `[object Object]` / `Stream Closed` /
|
|
32947
|
+
* `AxiosError: Network Error`, or the server replies `400 "No files uploaded."`).
|
|
32948
|
+
*
|
|
32949
|
+
* The correct behaviour for the React Native / browser environment is to let
|
|
32950
|
+
* the platform networking layer (XMLHttpRequest) serialize the `FormData` and
|
|
32951
|
+
* generate the `multipart/form-data; boundary=…` header itself. So we must NOT
|
|
32952
|
+
* set the content-type at all in that environment.
|
|
32953
|
+
*
|
|
32954
|
+
* We also pin `adapter: 'xhr'` so axios always routes the request through React
|
|
32955
|
+
* Native's `XMLHttpRequest` (which understands RN file parts), rather than
|
|
32956
|
+
* auto-selecting the `fetch` adapter that the New Architecture now also exposes.
|
|
32957
|
+
*
|
|
32958
|
+
* On Node (the `form-data` package exposes `getHeaders()`), we keep using its
|
|
32959
|
+
* generated headers — which already include the correct boundary — and leave
|
|
32960
|
+
* the adapter selection to axios (its http adapter, via the configured agents).
|
|
32961
|
+
*
|
|
32962
|
+
* @param formData The multipart payload about to be uploaded.
|
|
32963
|
+
* @returns A partial axios config to spread into the upload request.
|
|
32964
|
+
*
|
|
32965
|
+
* @category File Util
|
|
32966
|
+
* @hidden
|
|
32967
|
+
*/
|
|
32968
|
+
const getUploadRequestConfig = (formData) => {
|
|
32969
|
+
// Node `form-data` instances expose getHeaders() (with a valid boundary).
|
|
32970
|
+
if ('getHeaders' in formData) {
|
|
32971
|
+
return { headers: formData.getHeaders() };
|
|
32972
|
+
}
|
|
32973
|
+
// React Native / browser: let XMLHttpRequest build the multipart body and set
|
|
32974
|
+
// `multipart/form-data; boundary=…`. Passing `null` removes any inherited
|
|
32975
|
+
// content-type so axios does not force `application/json`.
|
|
32976
|
+
return {
|
|
32977
|
+
headers: { 'Content-Type': null },
|
|
32978
|
+
adapter: 'xhr',
|
|
32979
|
+
};
|
|
32980
|
+
};
|
|
32981
|
+
|
|
32938
32982
|
/* begin_public_function
|
|
32939
32983
|
id: file.upload.file
|
|
32940
32984
|
*/
|
|
@@ -32962,15 +33006,9 @@ const uploadFile = async (formData, onProgress) => {
|
|
|
32962
33006
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
32963
33007
|
formData.append('accessType', accessType);
|
|
32964
33008
|
formData.append('preferredFilename', files[0].name);
|
|
32965
|
-
const
|
|
32966
|
-
? formData.getHeaders()
|
|
32967
|
-
: { 'content-type': 'multipart/form-data' };
|
|
32968
|
-
const { data } = await client.upload.post('/api/v4/files', formData, {
|
|
32969
|
-
headers,
|
|
32970
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
33009
|
+
const { data } = await client.upload.post('/api/v4/files', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
32971
33010
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
32972
|
-
}
|
|
32973
|
-
});
|
|
33011
|
+
} }));
|
|
32974
33012
|
// API-FIX: payload should be serialized properly
|
|
32975
33013
|
// const { files } = data
|
|
32976
33014
|
const cachedAt = client.cache && Date.now();
|
|
@@ -33052,15 +33090,9 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
33052
33090
|
if (feedType) {
|
|
33053
33091
|
formData.append('feedType', feedType);
|
|
33054
33092
|
}
|
|
33055
|
-
const
|
|
33056
|
-
? formData.getHeaders()
|
|
33057
|
-
: { 'content-type': 'multipart/form-data' };
|
|
33058
|
-
const { data } = await client.upload.post('/api/v4/videos', formData, {
|
|
33059
|
-
headers,
|
|
33060
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
33093
|
+
const { data } = await client.upload.post('/api/v4/videos', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
33061
33094
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
33062
|
-
}
|
|
33063
|
-
});
|
|
33095
|
+
} }));
|
|
33064
33096
|
// API-FIX: payload should be serialized properly
|
|
33065
33097
|
// const { files } = data
|
|
33066
33098
|
const cachedAt = client.cache && Date.now();
|
|
@@ -33113,15 +33145,9 @@ const uploadImage = async (formData, onProgress, altText) => {
|
|
|
33113
33145
|
}
|
|
33114
33146
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
33115
33147
|
formData.append('accessType', accessType);
|
|
33116
|
-
const
|
|
33117
|
-
? formData.getHeaders()
|
|
33118
|
-
: { 'content-type': 'multipart/form-data' };
|
|
33119
|
-
const { data } = await client.upload.post('/api/v4/images', formData, {
|
|
33120
|
-
headers,
|
|
33121
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
33148
|
+
const { data } = await client.upload.post('/api/v4/images', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
33122
33149
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
33123
|
-
}
|
|
33124
|
-
});
|
|
33150
|
+
} }));
|
|
33125
33151
|
// API-FIX: payload should be serialized properly
|
|
33126
33152
|
// const { files } = data
|
|
33127
33153
|
const cachedAt = client.cache && Date.now();
|
|
@@ -33195,15 +33221,9 @@ const uploadClip = async (formData, feedType, onProgress) => {
|
|
|
33195
33221
|
if (feedType) {
|
|
33196
33222
|
formData.append('feedType', feedType);
|
|
33197
33223
|
}
|
|
33198
|
-
const
|
|
33199
|
-
? formData.getHeaders()
|
|
33200
|
-
: { 'content-type': 'multipart/form-data' };
|
|
33201
|
-
const { data } = await client.upload.post('/api/v4/clips', formData, {
|
|
33202
|
-
headers,
|
|
33203
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
33224
|
+
const { data } = await client.upload.post('/api/v4/clips', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
33204
33225
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
33205
|
-
}
|
|
33206
|
-
});
|
|
33226
|
+
} }));
|
|
33207
33227
|
// API-FIX: payload should be serialized properly
|
|
33208
33228
|
// const { files } = data
|
|
33209
33229
|
const cachedAt = client.cache && Date.now();
|
|
@@ -33244,13 +33264,9 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
33244
33264
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
33245
33265
|
formData.append('accessType', accessType);
|
|
33246
33266
|
formData.append('preferredFilename', file.name);
|
|
33247
|
-
const
|
|
33248
|
-
const { data } = await client.upload.post('/api/v4/audios', formData, {
|
|
33249
|
-
headers,
|
|
33250
|
-
onUploadProgress({ loaded, total = 100 }) {
|
|
33267
|
+
const { data } = await client.upload.post('/api/v4/audios', formData, Object.assign(Object.assign({}, getUploadRequestConfig(formData)), { onUploadProgress({ loaded, total = 100 }) {
|
|
33251
33268
|
onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.round((loaded * 100) / total));
|
|
33252
|
-
}
|
|
33253
|
-
});
|
|
33269
|
+
} }));
|
|
33254
33270
|
const cachedAt = client.cache && Date.now();
|
|
33255
33271
|
if (client.cache)
|
|
33256
33272
|
ingestInCache({ files: data }, { cachedAt });
|