import réussi

Dev
mohamed 2 years ago
parent a3d83b19fd
commit 964f0e2ba8

17162
R-Dash/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -16,18 +16,22 @@
"@reduxjs/toolkit": "^1.9.3",
"@rneui/base": "^4.0.0-rc.7",
"expo": "~48.0.6",
"expo-document-picker": "~11.2.1",
"expo-document-picker": "~11.2.2",
"expo-status-bar": "~1.4.4",
"jsonwebtoken": "^9.0.0",
"react": "18.2.0",
"react-native": "0.71.3",
"react-native": "0.71.4",
"react-native-document-picker": "^8.2.0",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.9.0",
"react-native-maps": "1.3.2",
"react-native-safe-area-context": "^4.5.0",
"react-redux": "^8.0.5",
"redux": "^4.2.1",
"typescript": "^4.9.4"
"typescript": "^4.9.4",
"react-native-web": "~0.18.10",
"react-dom": "18.2.0",
"@expo/webpack-config": "^18.0.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",

@ -5,6 +5,8 @@ import TopBar from '../components/TopBar';
import { addXlsFile } from '../redux/actions/sessions';
import { useDispatch } from 'react-redux';
import * as DocumentPicker from 'expo-document-picker';
import { uploadFiles, DocumentDirectoryPath } from 'react-native-fs';
export default function NewTrack(props: { navigation: any }) {
const { navigation } = props;
const dispatch = useDispatch();
@ -27,6 +29,15 @@ export default function NewTrack(props: { navigation: any }) {
console.log(err);
}
};
// var files = [
// {
// name: "file",
// filename: "file.jpg",
// filepath: pickedDocument.uri,
// filetype: "image/jpeg",
// },
// ];
// const handleConfirm = async () => {
@ -93,30 +104,34 @@ export default function NewTrack(props: { navigation: any }) {
return;
}
try {
const file = new File([await pickedDocument.uri], pickedDocument.name, { type: pickedDocument.type });
const url = 'https://r-dash.azurewebsites.net/File?pseudoPilote=test_PILOTE&nameSession=weeke&nameCircuit=test_CIRCUIT&typeSession=Training';
//const file = new File([await pickedDocument.uri], pickedDocument.name, { type: pickedDocument.type });
const url = 'https://r-dash.azurewebsites.net/File?pseudoPilote=test_PILOTE&nameSession=test%20import&nameCircuit=test_CIRCUIT&typeSession=Training';
const formData = new FormData();
formData.append('file', file);
// formData.append('pseudoPilote', 'test_PILOTE');
// formData.append('nameSession', sessionName);
// formData.append('nameCircuit', 'test_CIRCUIT');
// formData.append('typeSession', 'Training');
console.log(pickedDocument.type);
console.log(pickedDocument.uri);
formData.append('file',
{
name: pickedDocument.name,
type: "application/vnd.ms-excel",
uri : pickedDocument.uri,
});
const response = await fetch(url, {
method: 'POST',
body: file,
body: formData,
headers: {
Accept: '*/*',
'accept':'*/*',
'Content-Type': 'multipart/form-data',
},
});
const data = await response.json();
console.log('API response:', data);
if (!response.ok) {
throw new Error('Failed to upload file');
throw new Error( JSON.stringify(response) + 'Failed to upload file');
}
const data = await response.json();
console.log('API response:', data);
navigation.goBack();
} catch (error) {
console.log('Error - POST FILE', error);

Loading…
Cancel
Save