@widergy/mobile-ui 2.1.0 → 2.1.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.1.1](https://github.com/widergy/mobile-ui/compare/v2.1.0...v2.1.1) (2025-10-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * attachment upload failure ([#461](https://github.com/widergy/mobile-ui/issues/461)) ([49ed4d1](https://github.com/widergy/mobile-ui/commit/49ed4d1a5100b259c579325cc6cf36af5e33ea04))
7
+
1
8
  # [2.1.0](https://github.com/widergy/mobile-ui/compare/v2.0.2...v2.1.0) (2025-10-17)
2
9
 
3
10
 
@@ -31,6 +31,13 @@ class FilePicker extends Component {
31
31
  allowedPDFUploadSizes,
32
32
  pdfFormatError
33
33
  } = this.props;
34
+
35
+ const getRealFileType = mimeType => {
36
+ if (!mimeType || typeof mimeType !== 'string') return null;
37
+ const parts = mimeType.split('/');
38
+ return parts[1]?.toLowerCase() || null;
39
+ };
40
+
34
41
  try {
35
42
  const normalizeTypes = types => {
36
43
  if (!types || types.length === 0) return DEFAULT_ALLOWED_TYPES;
@@ -71,7 +78,8 @@ class FilePicker extends Component {
71
78
  onMaxSizeError(document.size, maxFileByteSize);
72
79
  return;
73
80
  }
74
- const file = !avoidRetrieveFile && (await retrieveFile(document.uri, document.type));
81
+ const realFileType = getRealFileType(document.type);
82
+ const file = !avoidRetrieveFile && (await retrieveFile(document.uri, realFileType));
75
83
 
76
84
  if (file && isPDF && !isEmpty(allowedPDFUploadSizes)) {
77
85
  const isWrongFormat = await pdfAspectRatioValidation(file, allowedPDFUploadSizes);
@@ -85,7 +93,7 @@ class FilePicker extends Component {
85
93
  }
86
94
  }
87
95
  if (onChange) {
88
- onChange(avoidRetrieveFile ? { document } : { file: blobToFile(file, document.type) });
96
+ onChange(avoidRetrieveFile ? { document } : { file: blobToFile(file, realFileType) });
89
97
  }
90
98
  this.setState({ fileName: document.name });
91
99
  } catch (err) {
@@ -57,7 +57,14 @@ const ImagePickerComponent = ({
57
57
  onError('No se pudo obtener el archivo');
58
58
  return;
59
59
  }
60
- const file = !avoidRetrieveFile && (await retrieveFile(item.uri, item.type));
60
+ const getRealFileType = mimeType => {
61
+ if (!mimeType || typeof mimeType !== 'string') return null;
62
+ const parts = mimeType.split('/');
63
+ return parts[1]?.toLowerCase() || null;
64
+ };
65
+ const realFileType = getRealFileType(item.type);
66
+
67
+ const file = !avoidRetrieveFile && (await retrieveFile(item.uri, realFileType));
61
68
  if (!avoidRetrieveFile && !file) {
62
69
  onError(response.errorCode);
63
70
  return;
@@ -79,6 +79,12 @@ const MultipleFilePicker = ({
79
79
 
80
80
  const remainingSlots = () => Math.max((maxFiles || 0) - uploadedFiles.length, 0);
81
81
 
82
+ const getRealFileType = mimeType => {
83
+ if (!mimeType || typeof mimeType !== 'string') return null;
84
+ const parts = mimeType.split('/');
85
+ return parts[1]?.toLowerCase() || null;
86
+ };
87
+
82
88
  const handleAssets = async response => {
83
89
  if (!response || response.didCancel) {
84
90
  return;
@@ -89,7 +95,8 @@ const MultipleFilePicker = ({
89
95
  }
90
96
  closeDrawer();
91
97
  response.assets.forEach(async asset => {
92
- const file = await retrieveFile(asset.uri, asset.type);
98
+ const realFileType = getRealFileType(asset.mimeType);
99
+ const file = await retrieveFile(asset.uri, realFileType);
93
100
  if (!file) {
94
101
  onError(response.errorCode || 'No se pudo obtener el archivo');
95
102
  return;
@@ -98,7 +105,7 @@ const MultipleFilePicker = ({
98
105
  if (isFileSizeInvaid({ size: file.size }, maxFileByteSize, onMaxSizeError)) return;
99
106
  setNewFile({
100
107
  uploadFile: { name: file.data.name, size: file.data.size },
101
- rawFile: blobToFile(file, asset.type)
108
+ rawFile: blobToFile(file, realFileType)
102
109
  });
103
110
  });
104
111
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@widergy/mobile-ui",
3
3
  "description": "Widergy Mobile Components",
4
4
  "author": "widergy",
5
- "version": "2.1.0",
5
+ "version": "2.1.1",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [