I am using google generative ai model gemini-1.5-pro for image analysis but getting error

Hello,

I am currently integrating the Google Generative AI API (specifically, the Gemini 1.5 Pro model) into my React Native application and have encountered an issue related to the file URI format. Below is the relevant portion of my code:

App.js: (React-Native)

import React, { useState, useEffect } from ‘react’;
import { View, Text } from ‘react-native’;
import { GoogleGenerativeAI } from ‘@google/generative-ai’;

const GEMINI_API_KEY = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’;

const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
const model = genAI.getGenerativeModel({
model: “gemini-1.5-pro”,
});

const App = () => {
const [generatedResponse, setGeneratedResponse] = useState(‘’);
const fileData = {
fileUri: ‘https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4’,
mimeType: ‘video/mp4’,
};

const prompt = “Describe this video clip”;
const videoPart = {
fileData: {
fileUri: fileData.fileUri,
mimeType: fileData.mimeType,
},
};

const generateContent = async () => {
try {
const result = await model.generateContent(prompt);
const responseText = await result.response.text();
setGeneratedResponse(responseText);
} catch (error) {
console.error(‘Error generating content’, error);
}
};

useEffect(() => {
generateContent();
}, );

return (
<View style={{ padding: 20 }}>
<Text style={{ fontSize: 24, fontWeight: ‘bold’ }}>Generated Response
<Text style={{ marginTop: 10 }}>{generatedResponse}

);
};

export default App;

Output:

Issue Description:

I am receiving a 400 error indicating an “Invalid or unsupported file uri.” It appears the file URI being used might not be supported by the API.

Could you please provide guidance on the correct format for the fileUri or any additional steps needed to resolve this issue?