@amityco/ts-sdk-react-native 6.28.3-54dff84.0 → 6.28.3
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/.env +26 -26
- package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
- package/dist/fileRepository/api/uploadVideo.d.ts.map +1 -1
- package/dist/index.cjs.js +16 -14
- package/dist/index.esm.js +16 -14
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
- package/src/fileRepository/api/uploadImage.ts +7 -5
- package/src/fileRepository/api/uploadVideo.ts +8 -7
package/package.json
CHANGED
|
@@ -33,19 +33,21 @@ export const uploadImage = async (
|
|
|
33
33
|
|
|
34
34
|
if (!files.length) throw new Error('The formData object must have a `files` key.');
|
|
35
35
|
|
|
36
|
+
const newFormDataWithMimeType = rebuildFormDataWithMimeType(formData);
|
|
37
|
+
|
|
36
38
|
const accessType = GlobalFileAccessType.getInstance().getFileAccessType();
|
|
37
|
-
|
|
39
|
+
newFormDataWithMimeType.append('accessType', accessType);
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
newFormDataWithMimeType.append('preferredFilename', (files[0] as File).name);
|
|
40
42
|
|
|
41
43
|
const headers =
|
|
42
|
-
'getHeaders' in
|
|
43
|
-
? (
|
|
44
|
+
'getHeaders' in newFormDataWithMimeType
|
|
45
|
+
? (newFormDataWithMimeType as any).getHeaders()
|
|
44
46
|
: { 'content-type': 'multipart/form-data' };
|
|
45
47
|
|
|
46
48
|
const { data } = await client.http.post<Amity.CreateFilePayload<'image'>>(
|
|
47
49
|
'/api/v4/images',
|
|
48
|
-
|
|
50
|
+
newFormDataWithMimeType,
|
|
49
51
|
{
|
|
50
52
|
headers,
|
|
51
53
|
onUploadProgress({ loaded, total = 100 }) {
|
|
@@ -35,23 +35,25 @@ export const uploadVideo = async (
|
|
|
35
35
|
|
|
36
36
|
if (!files.length) throw new Error('The formData object must have a `files` key.');
|
|
37
37
|
|
|
38
|
+
const newFormDataWithMimeType = rebuildFormDataWithMimeType(formData);
|
|
39
|
+
|
|
38
40
|
const accessType = GlobalFileAccessType.getInstance().getFileAccessType();
|
|
39
|
-
|
|
41
|
+
newFormDataWithMimeType.append('accessType', accessType);
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
newFormDataWithMimeType.append('preferredFilename', (files[0] as File).name);
|
|
42
44
|
|
|
43
45
|
if (feedType) {
|
|
44
|
-
|
|
46
|
+
newFormDataWithMimeType.append('feedType', feedType);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const headers =
|
|
48
|
-
'getHeaders' in
|
|
49
|
-
? (
|
|
50
|
+
'getHeaders' in newFormDataWithMimeType
|
|
51
|
+
? (newFormDataWithMimeType as any).getHeaders()
|
|
50
52
|
: { 'content-type': 'multipart/form-data' };
|
|
51
53
|
|
|
52
54
|
const { data } = await client.http.post<Amity.CreateFilePayload<'video'>>(
|
|
53
55
|
'/api/v4/videos',
|
|
54
|
-
|
|
56
|
+
newFormDataWithMimeType,
|
|
55
57
|
{
|
|
56
58
|
headers,
|
|
57
59
|
onUploadProgress({ loaded, total = 100 }) {
|
|
@@ -59,7 +61,6 @@ export const uploadVideo = async (
|
|
|
59
61
|
},
|
|
60
62
|
},
|
|
61
63
|
);
|
|
62
|
-
|
|
63
64
|
// API-FIX: payload should be serialized properly
|
|
64
65
|
// const { files } = data
|
|
65
66
|
|