Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
How to get permission to access camera in NodeJS on android

I want to write a non-typical android app -- a server app, in fact. When the server receives a request, it needs to capture an image from a camera, do some custom processing, and send a response to the client.

The nodejs service I wrote (see below) uses dory for the nodejs install. The service works on my desktop PC. But the node-webcam package does not support mobile phones. I haven't been able to find a package that support cameras on android.

Is there a way to access the camera on android?

const http = require('http');
const NodeWebcam = require( "node-webcam" );

const app = http.createServer((req, res) => {
    if( req.url === "/image" ) {
        var opts = {
            callbackReturn: "base64"
        };
        NodeWebcam.capture( "test_picture", opts, function( err, data ) {
            let imageHTML = "<div>Error: " + JSON.stringify(err) + "</div>";
            if( data ) {
                imageHTML = "<img src='" + data + "'>";
            }
            // Set a response type of plain text for the response
            res.writeHead(200, {'Content-Type': 'text/html'});
            // Send back a response and end the connection
            res.end(`<html><body>${imageHTML}</body></html>`);
        });
    }
    else {
        // Set a response type of plain text for the response
        res.writeHead(200, {'Content-Type': 'text/plain'});

        // Send back a response and end the connection
        res.end('NodeJS Server Online!\n\nContent is king!');
    }
});

// Start the server on port 3000
app.listen(3000, '0.0.0.0');
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!