@tradly/asset 1.0.18 → 1.0.20

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.
@@ -249,7 +249,7 @@ var MediaApiService = /*#__PURE__*/function () {
249
249
  key: "uploadMedia",
250
250
  value: (function () {
251
251
  var _uploadMedia = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(files, authKey) {
252
- var auth_key, all_files_uri, upload_files, upload_full_files, i, element, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, blob, res, mediaData, _t3, _t4, _t5;
252
+ var auth_key, all_files_uri, upload_files, upload_full_files, i, element, cleanFileName, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, arrayBuffer, res, errorText, errorMsg, mediaData, _t3, _t4, _t5;
253
253
  return _regenerator().w(function (_context4) {
254
254
  while (1) switch (_context4.p = _context4.n) {
255
255
  case 0:
@@ -266,7 +266,7 @@ var MediaApiService = /*#__PURE__*/function () {
266
266
  i = 0;
267
267
  case 2:
268
268
  if (!(i < files.length)) {
269
- _context4.n = 21;
269
+ _context4.n = 27;
270
270
  break;
271
271
  }
272
272
  element = files[i]; // Check if file already has a path (from previous upload)
@@ -274,9 +274,11 @@ var MediaApiService = /*#__PURE__*/function () {
274
274
  all_files_uri.push(element.path);
275
275
  } else {
276
276
  // Prepare file data for upload
277
+ // Clean file name: remove spaces (following user's pattern: fileName.replace(/ /g, ""))
278
+ cleanFileName = element.name.replace(/\s/g, "");
277
279
  file_data = {
278
- name: element.name.replace(/\s/g, "-"),
279
- type: element.type
280
+ name: cleanFileName,
281
+ type: element.type || "image/jpeg" // Default MIME type
280
282
  };
281
283
  upload_files.push(file_data);
282
284
  upload_full_files.push(element);
@@ -284,7 +286,7 @@ var MediaApiService = /*#__PURE__*/function () {
284
286
 
285
287
  // Upload files when we've processed all files
286
288
  if (!(files.length === i + 1 && upload_files.length > 0)) {
287
- _context4.n = 20;
289
+ _context4.n = 26;
288
290
  break;
289
291
  }
290
292
  _context4.p = 3;
@@ -295,7 +297,7 @@ var MediaApiService = /*#__PURE__*/function () {
295
297
  index = 0;
296
298
  case 5:
297
299
  if (!(index < responseFiles.length)) {
298
- _context4.n = 17;
300
+ _context4.n = 23;
299
301
  break;
300
302
  }
301
303
  path = responseFiles[index].signedUrl;
@@ -305,7 +307,7 @@ var MediaApiService = /*#__PURE__*/function () {
305
307
  fileBody = originalFile; // Handle React Native file URIs
306
308
  // If file has a uri property, it's from React Native - fetch it first
307
309
  if (!(originalFile.uri && typeof originalFile.uri === "string")) {
308
- _context4.n = 13;
310
+ _context4.n = 16;
309
311
  break;
310
312
  }
311
313
  // For React Native, handle file://, content://, or http:// URIs
@@ -315,63 +317,102 @@ var MediaApiService = /*#__PURE__*/function () {
315
317
  return fetch(uri);
316
318
  case 8:
317
319
  fileResponse = _context4.v;
320
+ if (fileResponse.ok) {
321
+ _context4.n = 9;
322
+ break;
323
+ }
324
+ throw new Error("Failed to fetch file: ".concat(fileResponse.status, " ").concat(fileResponse.statusText));
325
+ case 9:
318
326
  if (!fileResponse.blob) {
319
- _context4.n = 10;
327
+ _context4.n = 11;
320
328
  break;
321
329
  }
322
- _context4.n = 9;
330
+ _context4.n = 10;
323
331
  return fileResponse.blob();
324
- case 9:
325
- blob = _context4.v;
326
- fileBody = blob;
327
- _context4.n = 11;
328
- break;
329
332
  case 10:
330
- // Fallback: use the response as-is if blob() is not available
331
- // Some React Native versions might need different handling
332
- fileBody = fileResponse;
333
- case 11:
334
- _context4.n = 13;
333
+ fileBody = _context4.v;
334
+ _context4.n = 14;
335
335
  break;
336
+ case 11:
337
+ if (!fileResponse.arrayBuffer) {
338
+ _context4.n = 13;
339
+ break;
340
+ }
341
+ _context4.n = 12;
342
+ return fileResponse.arrayBuffer();
336
343
  case 12:
337
- _context4.p = 12;
338
- _t3 = _context4.v;
339
- // If fetch fails, try using the URI directly
340
- // Some React Native environments might handle this differently
341
- console.warn("Fetch failed for URI, trying direct upload:", _t3);
342
- // For S3 PUT, we need the actual file content
343
- // If fetch fails, we'll try to use the file object directly
344
- // This might require additional React Native file handling libraries
345
- throw new Error("Failed to read file from URI: ".concat(uri, ". Make sure the file URI is accessible. Error: ").concat(_t3.message));
346
- case 13:
344
+ arrayBuffer = _context4.v;
345
+ // Check if Blob constructor is available
346
+ if (typeof Blob !== "undefined") {
347
+ fileBody = new Blob([arrayBuffer], {
348
+ type: upload_files[index].type
349
+ });
350
+ } else {
351
+ // If Blob is not available, use arrayBuffer directly
352
+ fileBody = arrayBuffer;
353
+ }
347
354
  _context4.n = 14;
355
+ break;
356
+ case 13:
357
+ // Last resort: use response directly (might not work for all cases)
358
+ fileBody = fileResponse;
359
+ case 14:
360
+ _context4.n = 16;
361
+ break;
362
+ case 15:
363
+ _context4.p = 15;
364
+ _t3 = _context4.v;
365
+ console.error("Error fetching file from URI:", _t3);
366
+ console.error("URI was:", uri);
367
+ console.error("File details:", {
368
+ name: originalFile.name,
369
+ type: originalFile.type
370
+ });
371
+ throw new Error("Failed to read file from URI: ".concat(uri, ". Error: ").concat(_t3.message, ". Make sure the file URI is accessible."));
372
+ case 16:
373
+ _context4.n = 17;
348
374
  return fetch(path, {
349
375
  method: "PUT",
350
376
  headers: {
351
- ContentType: upload_files[index].type
377
+ "Content-Type": upload_files[index].type
352
378
  },
353
379
  body: fileBody
354
380
  });
355
- case 14:
381
+ case 17:
356
382
  res = _context4.v;
357
- if (res.ok) {
358
- all_files_uri.push(fileURI);
359
- } else {
360
- console.error("Failed to upload file ".concat(index + 1));
383
+ if (!res.ok) {
384
+ _context4.n = 18;
385
+ break;
361
386
  }
362
- _context4.n = 16;
387
+ all_files_uri.push(fileURI);
388
+ _context4.n = 20;
363
389
  break;
364
- case 15:
365
- _context4.p = 15;
390
+ case 18:
391
+ _context4.n = 19;
392
+ return res.text().catch(function () {
393
+ return "";
394
+ });
395
+ case 19:
396
+ errorText = _context4.v;
397
+ console.error("Failed to upload file ".concat(index + 1, ":"), res.status, res.statusText, errorText);
398
+ errorMsg = errorText ? "S3 upload failed: ".concat(res.status, " ").concat(res.statusText, " - ").concat(errorText) : "S3 upload failed: ".concat(res.status, " ").concat(res.statusText);
399
+ throw new Error(errorMsg);
400
+ case 20:
401
+ _context4.n = 22;
402
+ break;
403
+ case 21:
404
+ _context4.p = 21;
366
405
  _t4 = _context4.v;
367
406
  console.error("Error uploading file ".concat(index + 1, ":"), _t4);
368
- case 16:
407
+ // Re-throw to stop the upload process
408
+ throw _t4;
409
+ case 22:
369
410
  index++;
370
411
  _context4.n = 5;
371
412
  break;
372
- case 17:
413
+ case 23:
373
414
  if (!(all_files_uri.length > 0)) {
374
- _context4.n = 18;
415
+ _context4.n = 24;
375
416
  break;
376
417
  }
377
418
  mediaData = all_files_uri.map(function (url, index) {
@@ -380,11 +421,11 @@ var MediaApiService = /*#__PURE__*/function () {
380
421
  type: 1,
381
422
  parent: 0,
382
423
  url: url,
383
- name: originalFile.name.replace(/\s/g, "-"),
424
+ name: originalFile.name.replace(/\s/g, ""),
384
425
  mime_type: originalFile.type
385
426
  };
386
427
  }); // Save to media API - POST /v1/media with { media: [...] }
387
- _context4.n = 18;
428
+ _context4.n = 24;
388
429
  return this.apiCall({
389
430
  method: "POST",
390
431
  path: "/v1/media",
@@ -392,25 +433,25 @@ var MediaApiService = /*#__PURE__*/function () {
392
433
  media: mediaData
393
434
  }
394
435
  });
395
- case 18:
396
- _context4.n = 20;
436
+ case 24:
437
+ _context4.n = 26;
397
438
  break;
398
- case 19:
399
- _context4.p = 19;
439
+ case 25:
440
+ _context4.p = 25;
400
441
  _t5 = _context4.v;
401
442
  console.error("Upload error:", _t5);
402
443
  if (this.onError) {
403
444
  this.onError(_t5);
404
445
  }
405
446
  throw _t5;
406
- case 20:
447
+ case 26:
407
448
  i++;
408
449
  _context4.n = 2;
409
450
  break;
410
- case 21:
451
+ case 27:
411
452
  return _context4.a(2, all_files_uri);
412
453
  }
413
- }, _callee4, this, [[7, 12], [6, 15], [3, 19]]);
454
+ }, _callee4, this, [[7, 15], [6, 21], [3, 25]]);
414
455
  }));
415
456
  function uploadMedia(_x5, _x6) {
416
457
  return _uploadMedia.apply(this, arguments);
@@ -243,7 +243,7 @@ var MediaApiService = /*#__PURE__*/function () {
243
243
  key: "uploadMedia",
244
244
  value: (function () {
245
245
  var _uploadMedia = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(files, authKey) {
246
- var auth_key, all_files_uri, upload_files, upload_full_files, i, element, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, blob, res, mediaData, _t3, _t4, _t5;
246
+ var auth_key, all_files_uri, upload_files, upload_full_files, i, element, cleanFileName, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, arrayBuffer, res, errorText, errorMsg, mediaData, _t3, _t4, _t5;
247
247
  return _regenerator().w(function (_context4) {
248
248
  while (1) switch (_context4.p = _context4.n) {
249
249
  case 0:
@@ -260,7 +260,7 @@ var MediaApiService = /*#__PURE__*/function () {
260
260
  i = 0;
261
261
  case 2:
262
262
  if (!(i < files.length)) {
263
- _context4.n = 21;
263
+ _context4.n = 27;
264
264
  break;
265
265
  }
266
266
  element = files[i]; // Check if file already has a path (from previous upload)
@@ -268,9 +268,11 @@ var MediaApiService = /*#__PURE__*/function () {
268
268
  all_files_uri.push(element.path);
269
269
  } else {
270
270
  // Prepare file data for upload
271
+ // Clean file name: remove spaces (following user's pattern: fileName.replace(/ /g, ""))
272
+ cleanFileName = element.name.replace(/\s/g, "");
271
273
  file_data = {
272
- name: element.name.replace(/\s/g, "-"),
273
- type: element.type
274
+ name: cleanFileName,
275
+ type: element.type || "image/jpeg" // Default MIME type
274
276
  };
275
277
  upload_files.push(file_data);
276
278
  upload_full_files.push(element);
@@ -278,7 +280,7 @@ var MediaApiService = /*#__PURE__*/function () {
278
280
 
279
281
  // Upload files when we've processed all files
280
282
  if (!(files.length === i + 1 && upload_files.length > 0)) {
281
- _context4.n = 20;
283
+ _context4.n = 26;
282
284
  break;
283
285
  }
284
286
  _context4.p = 3;
@@ -289,7 +291,7 @@ var MediaApiService = /*#__PURE__*/function () {
289
291
  index = 0;
290
292
  case 5:
291
293
  if (!(index < responseFiles.length)) {
292
- _context4.n = 17;
294
+ _context4.n = 23;
293
295
  break;
294
296
  }
295
297
  path = responseFiles[index].signedUrl;
@@ -299,7 +301,7 @@ var MediaApiService = /*#__PURE__*/function () {
299
301
  fileBody = originalFile; // Handle React Native file URIs
300
302
  // If file has a uri property, it's from React Native - fetch it first
301
303
  if (!(originalFile.uri && typeof originalFile.uri === "string")) {
302
- _context4.n = 13;
304
+ _context4.n = 16;
303
305
  break;
304
306
  }
305
307
  // For React Native, handle file://, content://, or http:// URIs
@@ -309,63 +311,102 @@ var MediaApiService = /*#__PURE__*/function () {
309
311
  return fetch(uri);
310
312
  case 8:
311
313
  fileResponse = _context4.v;
314
+ if (fileResponse.ok) {
315
+ _context4.n = 9;
316
+ break;
317
+ }
318
+ throw new Error("Failed to fetch file: ".concat(fileResponse.status, " ").concat(fileResponse.statusText));
319
+ case 9:
312
320
  if (!fileResponse.blob) {
313
- _context4.n = 10;
321
+ _context4.n = 11;
314
322
  break;
315
323
  }
316
- _context4.n = 9;
324
+ _context4.n = 10;
317
325
  return fileResponse.blob();
318
- case 9:
319
- blob = _context4.v;
320
- fileBody = blob;
321
- _context4.n = 11;
322
- break;
323
326
  case 10:
324
- // Fallback: use the response as-is if blob() is not available
325
- // Some React Native versions might need different handling
326
- fileBody = fileResponse;
327
- case 11:
328
- _context4.n = 13;
327
+ fileBody = _context4.v;
328
+ _context4.n = 14;
329
329
  break;
330
+ case 11:
331
+ if (!fileResponse.arrayBuffer) {
332
+ _context4.n = 13;
333
+ break;
334
+ }
335
+ _context4.n = 12;
336
+ return fileResponse.arrayBuffer();
330
337
  case 12:
331
- _context4.p = 12;
332
- _t3 = _context4.v;
333
- // If fetch fails, try using the URI directly
334
- // Some React Native environments might handle this differently
335
- console.warn("Fetch failed for URI, trying direct upload:", _t3);
336
- // For S3 PUT, we need the actual file content
337
- // If fetch fails, we'll try to use the file object directly
338
- // This might require additional React Native file handling libraries
339
- throw new Error("Failed to read file from URI: ".concat(uri, ". Make sure the file URI is accessible. Error: ").concat(_t3.message));
340
- case 13:
338
+ arrayBuffer = _context4.v;
339
+ // Check if Blob constructor is available
340
+ if (typeof Blob !== "undefined") {
341
+ fileBody = new Blob([arrayBuffer], {
342
+ type: upload_files[index].type
343
+ });
344
+ } else {
345
+ // If Blob is not available, use arrayBuffer directly
346
+ fileBody = arrayBuffer;
347
+ }
341
348
  _context4.n = 14;
349
+ break;
350
+ case 13:
351
+ // Last resort: use response directly (might not work for all cases)
352
+ fileBody = fileResponse;
353
+ case 14:
354
+ _context4.n = 16;
355
+ break;
356
+ case 15:
357
+ _context4.p = 15;
358
+ _t3 = _context4.v;
359
+ console.error("Error fetching file from URI:", _t3);
360
+ console.error("URI was:", uri);
361
+ console.error("File details:", {
362
+ name: originalFile.name,
363
+ type: originalFile.type
364
+ });
365
+ throw new Error("Failed to read file from URI: ".concat(uri, ". Error: ").concat(_t3.message, ". Make sure the file URI is accessible."));
366
+ case 16:
367
+ _context4.n = 17;
342
368
  return fetch(path, {
343
369
  method: "PUT",
344
370
  headers: {
345
- ContentType: upload_files[index].type
371
+ "Content-Type": upload_files[index].type
346
372
  },
347
373
  body: fileBody
348
374
  });
349
- case 14:
375
+ case 17:
350
376
  res = _context4.v;
351
- if (res.ok) {
352
- all_files_uri.push(fileURI);
353
- } else {
354
- console.error("Failed to upload file ".concat(index + 1));
377
+ if (!res.ok) {
378
+ _context4.n = 18;
379
+ break;
355
380
  }
356
- _context4.n = 16;
381
+ all_files_uri.push(fileURI);
382
+ _context4.n = 20;
357
383
  break;
358
- case 15:
359
- _context4.p = 15;
384
+ case 18:
385
+ _context4.n = 19;
386
+ return res.text().catch(function () {
387
+ return "";
388
+ });
389
+ case 19:
390
+ errorText = _context4.v;
391
+ console.error("Failed to upload file ".concat(index + 1, ":"), res.status, res.statusText, errorText);
392
+ errorMsg = errorText ? "S3 upload failed: ".concat(res.status, " ").concat(res.statusText, " - ").concat(errorText) : "S3 upload failed: ".concat(res.status, " ").concat(res.statusText);
393
+ throw new Error(errorMsg);
394
+ case 20:
395
+ _context4.n = 22;
396
+ break;
397
+ case 21:
398
+ _context4.p = 21;
360
399
  _t4 = _context4.v;
361
400
  console.error("Error uploading file ".concat(index + 1, ":"), _t4);
362
- case 16:
401
+ // Re-throw to stop the upload process
402
+ throw _t4;
403
+ case 22:
363
404
  index++;
364
405
  _context4.n = 5;
365
406
  break;
366
- case 17:
407
+ case 23:
367
408
  if (!(all_files_uri.length > 0)) {
368
- _context4.n = 18;
409
+ _context4.n = 24;
369
410
  break;
370
411
  }
371
412
  mediaData = all_files_uri.map(function (url, index) {
@@ -374,11 +415,11 @@ var MediaApiService = /*#__PURE__*/function () {
374
415
  type: 1,
375
416
  parent: 0,
376
417
  url: url,
377
- name: originalFile.name.replace(/\s/g, "-"),
418
+ name: originalFile.name.replace(/\s/g, ""),
378
419
  mime_type: originalFile.type
379
420
  };
380
421
  }); // Save to media API - POST /v1/media with { media: [...] }
381
- _context4.n = 18;
422
+ _context4.n = 24;
382
423
  return this.apiCall({
383
424
  method: "POST",
384
425
  path: "/v1/media",
@@ -386,25 +427,25 @@ var MediaApiService = /*#__PURE__*/function () {
386
427
  media: mediaData
387
428
  }
388
429
  });
389
- case 18:
390
- _context4.n = 20;
430
+ case 24:
431
+ _context4.n = 26;
391
432
  break;
392
- case 19:
393
- _context4.p = 19;
433
+ case 25:
434
+ _context4.p = 25;
394
435
  _t5 = _context4.v;
395
436
  console.error("Upload error:", _t5);
396
437
  if (this.onError) {
397
438
  this.onError(_t5);
398
439
  }
399
440
  throw _t5;
400
- case 20:
441
+ case 26:
401
442
  i++;
402
443
  _context4.n = 2;
403
444
  break;
404
- case 21:
445
+ case 27:
405
446
  return _context4.a(2, all_files_uri);
406
447
  }
407
- }, _callee4, this, [[7, 12], [6, 15], [3, 19]]);
448
+ }, _callee4, this, [[7, 15], [6, 21], [3, 25]]);
408
449
  }));
409
450
  function uploadMedia(_x5, _x6) {
410
451
  return _uploadMedia.apply(this, arguments);
@@ -2,6 +2,7 @@ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present,
2
2
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
3
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
4
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
6
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
6
7
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
8
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -80,6 +81,7 @@ var FileUpload = function FileUpload(_ref) {
80
81
  picker = _ref.picker,
81
82
  pickerOptions = _ref.pickerOptions,
82
83
  icon = _ref.icon,
84
+ icons = _ref.icons,
83
85
  _ref$theme = _ref.theme,
84
86
  theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
85
87
  containerStyle = _ref.containerStyle,
@@ -96,6 +98,26 @@ var FileUpload = function FileUpload(_ref) {
96
98
  uploadProgress = _useState4[0],
97
99
  setUploadProgress = _useState4[1];
98
100
 
101
+ // Determine which icon to use based on accept type and icons prop
102
+ var getIcon = function getIcon() {
103
+ // If icons object is provided, use it to select based on accept type
104
+ if (icons && _typeof(icons) === "object") {
105
+ var isImage = accept === null || accept === void 0 ? void 0 : accept.includes("image");
106
+ var isVideo = accept === null || accept === void 0 ? void 0 : accept.includes("video");
107
+ if (isImage && icons.image) {
108
+ return icons.image;
109
+ } else if (isVideo && icons.video) {
110
+ return icons.video;
111
+ } else if (icons.default) {
112
+ return icons.default;
113
+ }
114
+ }
115
+
116
+ // Fallback to single icon prop (backward compatibility)
117
+ return icon;
118
+ };
119
+ var selectedIcon = getIcon();
120
+
99
121
  // Convert file picker result to File-like object for apiService
100
122
  var convertToFile = function convertToFile(pickerResult) {
101
123
  // Handle different picker formats:
@@ -116,22 +138,39 @@ var FileUpload = function FileUpload(_ref) {
116
138
  fileName = lastPart ? lastPart.split("?")[0] : null; // Remove query params if any
117
139
  }
118
140
 
119
- // Final fallback
141
+ // Final fallback - generate a meaningful filename
120
142
  if (!fileName) {
121
143
  // Try to guess from mimeType
122
144
  var _mimeType = pickerResult.mimeType || pickerResult.type || "";
145
+ var timestamp = Date.now();
123
146
  if (_mimeType.includes("image")) {
124
- fileName = _mimeType.includes("jpeg") || _mimeType.includes("jpg") ? "image.jpg" : _mimeType.includes("png") ? "image.png" : _mimeType.includes("gif") ? "image.gif" : "image.jpg";
147
+ fileName = _mimeType.includes("jpeg") || _mimeType.includes("jpg") ? "image_".concat(timestamp, ".jpg") : _mimeType.includes("png") ? "image_".concat(timestamp, ".png") : _mimeType.includes("gif") ? "image_".concat(timestamp, ".gif") : _mimeType.includes("webp") ? "image_".concat(timestamp, ".webp") : "image_".concat(timestamp, ".jpg");
125
148
  } else if (_mimeType.includes("video")) {
126
- fileName = "video.mp4";
149
+ fileName = _mimeType.includes("mp4") ? "video_".concat(timestamp, ".mp4") : _mimeType.includes("mov") ? "video_".concat(timestamp, ".mov") : "video_".concat(timestamp, ".mp4");
127
150
  } else {
128
- fileName = "file";
151
+ fileName = "file_".concat(timestamp);
129
152
  }
130
153
  }
131
154
 
132
155
  // Extract MIME type (handle different property names)
133
- var mimeType = pickerResult.mimeType || pickerResult.type || "image/jpeg"; // Default fallback
134
-
156
+ // Use a helper function to determine MIME type from filename if needed
157
+ var getMimeType = function getMimeType(name, fallbackType) {
158
+ var _name$split$pop;
159
+ if (fallbackType) return fallbackType;
160
+ var ext = (_name$split$pop = name.split(".").pop()) === null || _name$split$pop === void 0 ? void 0 : _name$split$pop.toLowerCase();
161
+ var mimeMap = {
162
+ jpg: "image/jpeg",
163
+ jpeg: "image/jpeg",
164
+ png: "image/png",
165
+ gif: "image/gif",
166
+ webp: "image/webp",
167
+ mp4: "video/mp4",
168
+ mov: "video/quicktime",
169
+ mp3: "audio/mpeg"
170
+ };
171
+ return mimeMap[ext] || "image/jpeg";
172
+ };
173
+ var mimeType = pickerResult.mimeType || pickerResult.type || getMimeType(fileName, null);
135
174
  return {
136
175
  uri: uri,
137
176
  name: fileName,
@@ -288,20 +327,20 @@ var FileUpload = function FileUpload(_ref) {
288
327
  borderRadius: theme.radius.md
289
328
  }, buttonStyle],
290
329
  disabled: isLoading,
291
- children: [icon && /*#__PURE__*/_jsx(View, {
330
+ children: [selectedIcon && /*#__PURE__*/_jsx(View, {
292
331
  style: [styles.iconContainer, {
293
332
  backgroundColor: theme.colors.uploadIconBackground,
294
333
  borderRadius: theme.radius.xl,
295
334
  marginBottom: theme.spacing.sm,
296
335
  padding: theme.spacing.md
297
336
  }, iconContainerStyle],
298
- children: icon
337
+ children: selectedIcon
299
338
  }), /*#__PURE__*/_jsx(Text, {
300
339
  style: [styles.title, {
301
340
  color: theme.colors.uploadText,
302
341
  fontSize: theme.typography.body.fontSize,
303
342
  fontWeight: theme.typography.body.fontWeight,
304
- marginTop: icon ? theme.spacing.sm : 0
343
+ marginTop: selectedIcon ? theme.spacing.sm : 0
305
344
  }, titleStyle],
306
345
  children: title
307
346
  })]
@@ -311,7 +350,7 @@ var FileUpload = function FileUpload(_ref) {
311
350
  var styles = StyleSheet.create({
312
351
  container: {
313
352
  width: "100%",
314
- height: 160
353
+ height: "100%"
315
354
  },
316
355
  button: {
317
356
  width: "100%",
@@ -327,11 +366,12 @@ var styles = StyleSheet.create({
327
366
  // Colors and spacing applied via theme
328
367
  },
329
368
  title: {
369
+ textAlign: "center"
330
370
  // Colors and typography applied via theme
331
371
  },
332
372
  loadingContainer: {
333
373
  width: "100%",
334
- height: 160,
374
+ height: "100%",
335
375
  justifyContent: "center",
336
376
  alignItems: "center"
337
377
  // Colors applied via theme