Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6213

react native upload image with axios

$
0
0

I have this datacame from react-native-image-picker

data: "/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2Qtan" => 90kbfileName: "77677.jpg"fileSize: 67542height: 600isVertical: trueoriginalRotation: 0path: "/storage/emulated/0/Download/77677.jpg"type: "image/jpeg"uri: "content://media/external/images/media/18584"width: 399__proto__: Object

and am try to set this data in object type #FromData to upload #img

var binaryDataInBase64 = new FormData();        binaryDataInBase64.append('file', {            // data: response.data,            uri: 'file://'+ response.uri,            name: 'MMM.jpg',            type: response.type        })        console.log('=======================>', binaryDataInBase64)        axios.post('https://danskeclouddemo.com/api/file',            { file: binaryDataInBase64 },            { headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'multipart/form-data'  } }        ).then(res => {            console.log(res)        }).catch(error => {            console.log(error)        })

and this is BackEnd Postman Working good Postman collection

//======================//======================Edit

Some people talk about the problem from react native version after 0.61.5in this link issues


Viewing all articles
Browse latest Browse all 6213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>