Skip to content

Can't connect to node server #11

@himanshujobletics

Description

@himanshujobletics

Hi,

I am trying to upload video file from react-native camera to node server on localhost but the the control is not going inside upload function. I did a console log of the FileUpload object and it is coming as undefined.
Could some one please help.

startRecording = () => {
if (this.camera) {
this.camera.capture({mode: Camera.constants.CaptureMode.video})
.then((data) =>{
var FileUpload = require('NativeModules').FileUpload;
var obj = {
uploadUrl: 'http://10.0.1.196:8000/answer',
method: 'POST', // default 'POST',support 'POST' and 'PUT'
headers: {
'Accept': 'application/json',
},
fields: {
'hello': 'world',
},
files: [
{
name: 'answer', // optional, if none then filename is used instead
filename: 'answer.mp4', // require, file name
filepath: data.path, // require, file absoluete path
filetype: 'video/mp4', // options, if none, will get mimetype from filepath extension
},
]
};
alert("object made"+FileUpload)
FileUpload.upload(obj, function(err, result) {
alert('upload:', err, result);
})

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions