Clarifai API for Local Image - node.js

I'm trying to make a nodejs application that captures an image from the computer's webcam, and then uses Clarifai API to recognize what is in that picture. I haven't figured out how to do that for local images, however, as the method I'm using, the one presented in the 'Getting Started' section of the API, only works with urls, and not local file paths.

ofcourse it works with localfile also but with client side java script SDK. (not with node js). for client side clarifai SDk add
<script type="text/javascript" src="https://sdk.clarifai.com/js/clarifai-latest.js"></script>
in html header and inti sdk using
const app = new Clarifai.App({
apiKey: 'YOUR_API_KEY'
});
by adding sdk you got Clarifai as global varible for example go to offical clarifai demo https://www.clarifai.com/demo and open console and type Clarifai and got magic,
if done this magic then now it's time to go https://clarifai.com/developer/guide/

Related

Display image on react app from node js server

I am creating an react app using create-react-app for school management system. I had used node js for creating api end point. I am able to store student detail and can fetch it back to display in react.
I had created an endpoint for uploading student images, which is also working perfect.
I had stored the image on node js server public folder. I know it should be on client public folder but if another application for example android or angular or vue application tries to call the same image will not get as it will be stored in react public folder.
So how could I solve the image problem?
You've done all the logic right, just add image URL to user profile, for example :
imageUrl: 'https://{your API URL}'
or the better way to upload all images on file server like S3 or Google Cloud Storage, and save only link to image on user profile

How to renderTextLayer of pdfjs in nodejs for SSR?

I have tried the pdfjs in browser javascript and it is working fine but if i try to render the textLayer in server side with nodejs it is throw error for canvas.
Anyone know how to make this happen in server side with nodejs?
I asked the same in offical github repo, and they replied it is possible with jsdom. but don't know how to do that
https://github.com/mozilla/pdf.js/issues/11011

How can update static files in node js app?

I have nodejs app using express module, i had been changes some images inside public folder but when i checked from users side still on the old images and when clear browser cache i get on new images , is there a command to make this automatically.
Have a look at Etag. If the content of the resource is not changed the server will not send it again. When it is, as in your case it will.
Looking at the express docs I see etag is an boolean option of the middleware function static.
express.static({etag: true})
Some background information about tags.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

How to create simple webhooks for asana

I'm new to asana API and need help in creating webhooks to track activities in asana. a simple example using NodeJS would be fine. thank you.
Check this out: https://github.com/Asana/node-asana
A JavaScript client (for both Node and browser) for the Asana API v1.0.
Install with npm:
npm install asana --save
Browser
Include the latest release directly from GitHub.
<script src="https://github.com/Asana/node-asana/releases/download/<LATEST_RELEASE>/asana-min.js"></script>
OR
Download the latest distribution in releases.
Make sure to serve it from your webserver.
Include it on the client from a SCRIPT tag.
Usage
To do anything, you'll need always an instance of an Asana.Client configured with your preferred authentication method and other options.
The most minimal example would be as follows:
const asana = require('asana');
const client = asana.Client.create().useAccessToken('my_access_token');
client.users.me().then(function(me) {
console.log(me);
});

How to : Read file from API (node) in my React app?

I work on an webapp which use REACT JS (with NODE, port 3000) and an API (with NODE JS, port 3100).
All requests made by client passing throught my API.
In this app, client could be able to listen mp3s downloaded and stored into my API. I made different schemas but I don't know which one can work.
SCHEMA 1.
REACT send parameters to API
API download the file and store it on a temporary directory
API send the URL (like : http://localhost:3100/sound/exemple.mp3) to REACT
REACT use that URL in 'src' of the AudioPlayer
Temporary files are delete with a CRON setting up on API server
I tried that solution but I have an error when I want to play the sound
(error: Can't GET /URL)
SCHEMA 2.
REACT send parameters to API
API download the file and store it on a temporary directory
REACT download the file from API and store it into public directory (by using express static)
REACT use that URL in 'src' of the AudioPlayer
Delete the file twice (API and REACT)
Another solution is to download the file directly from my source on REACT. But I need to hide the URL of the source (that why I pass throught my API).
Maybe there are others solutions ?

Resources