Help with React-Native upload to Cloudinary #511
Replies: 3 comments 5 replies
-
I think better documentation on the uploader arguments and what is expected for the sender to work would be helpful here. |
Beta Was this translation helpful? Give feedback.
-
I faced some issue in react native. when we pressed upload image, the error message shows: import React, { useState } from 'react' const options ={ const Request = () => { return ( ) const styles = StyleSheet.create({ when we pressed upload button, the error message shows: Possible Unhandled Promise Rejection (id: 1): I create API: const file = req.files.image; |
Beta Was this translation helpful? Give feedback.
-
I faced some issue in react native. when we pressed upload image, the error
message shows:
How to call this API, when we upload image in front end side, the image
will be stored in mongodb
I create API:
app.post('/finerequest', (req, res, next) => {
const file = req.files.image;
cloudinary.uploader.upload(file.tempFilePath, (err, result) => {
console.log(result)
const requestId = req.body.request_id
const fine = new Fine({
_id: new mongoose.Types.ObjectId,
request_id: requestId,
image: result.url
})
fine.save()
.then(result => {
res.status(200).json({
message: "Fine and Vehicle Repair Request added",
response: result
})
})
.catch(err => {
res.status(500).json({
message: "Fine and Vehicle request not added",
error: err
})
})
})
})
CODE:
import React, { useState } from 'react'
import { Alert, Button, View,StyleSheet } from 'react-native'
import * as ImagePicker from 'react-native-image-picker'
import {launchImageLibrary} from 'react-native-image-picker'
const options ={
title: 'Select Image',
type: 'library',
options: {
maxHeight:200,
maxWidth:200,
selectionLimit: 1,
mediaType: 'photo',
includeBase64: false,
}
}
const Request = () => {
const opengallery = async()=>{
const image = await ImagePicker.launchImageLibrary(options);
console.log(image)
}
return (
)
}
export default Request;
const styles = StyleSheet.create({
container:{
flex:1,
alignItems:'center',
justifyContent:'center'
}
})
when we pressed upload button, the error message shows:
Possible Unhandled Promise Rejection (id: 1):
TypeError: Cannot read property 'launchImageLibrary' of null
TypeError: Cannot read property 'launchImageLibrary' of null
Again and again same error show, we Image picker library, I think it has
been deprecated
…On Mon, Jul 17, 2023 at 12:19 AM Matthew Brimmer ***@***.***> wrote:
Oh wait, you are using react-native-image-picker and I am using
expo-image-picker
—
Reply to this email directly, view it on GitHub
<#511 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6W6U3EKJH6CNRCMI5QXN7TXQQ5FVANCNFSM6AAAAAAWYM3UDM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am struggling with this example, the main difference is I am using Expo and thus expo-image-picker. When passing the file to upload it attempts to upload to Cloudinary but the response is an error "Unsupported source URL": "path/to/file/on/device". I think this is because the URL should contain the data. Something similar to what is mentioned here.
I have tried building an input object based on the types declares for
UploadInfo
and I get "Error: Unknown type of file added: object"I think I have this working by using this to build the file path with the data
Beta Was this translation helpful? Give feedback.
All reactions