@umituz/react-native-ai-pruna-provider 1.0.19 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-pruna-provider",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
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",
@@ -42,9 +42,10 @@ export async function uploadFileToStorage(
42
42
 
43
43
  generationLogCollector.log(sessionId, TAG, 'Uploading file to Pruna storage...');
44
44
 
45
- // Strip data URI prefix if present
45
+ // Strip data URI prefix if present to get raw base64
46
46
  const raw = base64Data.includes('base64,') ? base64Data.split('base64,')[1] : base64Data;
47
47
 
48
+ // Decode base64 to get binary data
48
49
  let binaryStr: string;
49
50
  try {
50
51
  binaryStr = atob(raw);
@@ -52,6 +53,7 @@ export async function uploadFileToStorage(
52
53
  throw new Error("Invalid file format. Please provide base64 or a valid URL.");
53
54
  }
54
55
 
56
+ // Convert to byte array for MIME detection
55
57
  const bytes = new Uint8Array(binaryStr.length);
56
58
  for (let i = 0; i < binaryStr.length; i++) {
57
59
  bytes[i] = binaryStr.charCodeAt(i);
@@ -59,9 +61,14 @@ export async function uploadFileToStorage(
59
61
 
60
62
  const mime = detectMimeType(bytes);
61
63
  const ext = getExtensionForMime(mime);
62
- const blob = new Blob([bytes], { type: mime });
64
+
65
+ // React Native FormData: use object format with uri (data URI)
63
66
  const formData = new FormData();
64
- formData.append('content', blob, `upload.${ext}`);
67
+ formData.append('content', {
68
+ uri: base64Data.startsWith('data:') ? base64Data : `data:${mime};base64,${raw}`,
69
+ type: mime,
70
+ name: `upload.${ext}`,
71
+ } as any);
65
72
 
66
73
  const startTime = Date.now();
67
74