When sending images to a react-native application, some image returns a Network Error.
I can not find the solution, because other image is sent perfectly. If anyone would have a solution for this problem!
let data = new FormData()
data.append('file', {
name: picture.uri.split('/').pop(),
type: picture.type,
uri: picture.uri
})
await axios.post(URL, data, {
headers: {
'Accept': 'application/json',
'Content-Type': `multipart/form-data;boundary='--${Date.now()}--'`
}
}).catch(err => console.log('ERROR', err))
const storage = multer.diskStorage({
destination(req, file, cb) {
console.log("destination", file)
cb(null, '../../cloud/channels/')
},
filename(req, file, cb) {
cb(null, Date.now() + path.extname(file.originalname))
}
})
const upload = multer({
storage,
limits: {
fileSize: 1024 * 1024 * 20
}
})
app.post('/', upload.single('file'),(req: Request, res: Response) => {
console.log('FILE', req.file)
return res.status(200).json({
result: 'ok'
})
})
thanks in advance ๐