@umituz/react-native-ai-pruna-provider 1.0.25 → 1.0.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-pruna-provider",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Pruna AI provider for React Native - implements IAIProvider interface for unified AI generation",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -57,46 +57,45 @@ export async function uploadFileToStorage(
57
57
  });
58
58
  }
59
59
 
60
+ // Detect MIME type BEFORE creating temp file (needed for FormData)
61
+ const mimeType = detectMimeType(base64Data);
62
+ const extension = getExtensionForMime(mimeType);
63
+ const filename = `upload.${extension}`;
64
+
60
65
  // Use design system filesystem to create temp file (React Native compatible)
61
- const tempUri = await base64ToTempFile(base64Data);
66
+ const tempUri = await base64ToTempFile(base64Data, filename);
62
67
 
63
68
  if (!tempUri) {
64
69
  throw new Error("Failed to create temporary file from base64 data");
65
70
  }
66
71
 
67
- try {
68
- // Fetch the temp file to get a Blob
69
- const response = await fetch(tempUri);
70
- const blob = await response.blob();
71
-
72
- // Use blob's MIME type (more accurate than base64 detection)
73
- const actualMimeType = blob.type || 'image/jpeg';
74
- const extension = getExtensionForMime(actualMimeType);
75
- const filename = `upload.${extension}`;
76
-
77
- generationLogCollector.log(sessionId, TAG, `Temp file created (${blob.size} bytes, type: ${actualMimeType}), uploading to Pruna as ${filename}...`);
72
+ generationLogCollector.log(sessionId, TAG, `Temp file created, uploading to Pruna as ${filename}...`);
78
73
 
79
- // __DEV__ detailed blob logging
80
- if (typeof __DEV__ !== 'undefined' && __DEV__) {
81
- console.log(`[DEV] [${TAG}] Blob details:`, {
82
- tempUri,
83
- blobSize: blob.size,
84
- blobType: blob.type,
85
- actualMimeType,
86
- extension,
87
- filename,
88
- });
89
- }
74
+ // __DEV__ detailed file info
75
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
76
+ console.log(`[DEV] [${TAG}] File details:`, {
77
+ tempUri,
78
+ filename,
79
+ mimeType,
80
+ extension,
81
+ });
82
+ }
90
83
 
91
- // Create FormData with the blob AND proper filename with extension
84
+ try {
85
+ // React Native FormData file upload format (uri + type + name)
92
86
  const formData = new FormData();
93
- formData.append('content', blob, filename);
87
+ formData.append('content', {
88
+ uri: tempUri,
89
+ type: mimeType,
90
+ name: filename,
91
+ } as any);
94
92
 
95
- // __DEV__ log FormData entries (if possible)
93
+ // __DEV__ log FormData
96
94
  if (typeof __DEV__ !== 'undefined' && __DEV__) {
97
- console.log(`[DEV] [${TAG}] FormData created:`, {
98
- hasContent: formData.has('content'),
95
+ console.log(`[DEV] [${TAG}] FormData created (RN file format):`, {
99
96
  filename,
97
+ mimeType,
98
+ hasContent: formData.has('content'),
100
99
  });
101
100
  }
102
101