Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main(fileName) {
// [START vision_batch_annotate_files_beta]
// Imports the Google Cloud client libraries
const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1;
const fs = require('fs');
const {promisify} = require('util');
const readFileAsync = promisify(fs.readFile);
// Creates a client
const client = new ImageAnnotatorClient();
/**
* TODO(developer): Uncomment the following line before running the sample.
*/
// const fileName = `/path/to/localDocument.pdf`;
const inputConfig = {
// Other supported mime_types: image/tiff' or 'image/gif'
mimeType: 'application/pdf',
content: await readFileAsync(fileName),
async function main(inputImageUri, outputUri) {
// [START vision_async_batch_annotate_images_beta]
// Imports the Google Cloud client libraries
const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1;
// Creates a client
const client = new ImageAnnotatorClient();
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// GCS path where the image resides
// const inputImageUri = 'gs://my-bucket/my_image.jpg';
// GCS path where to store the output json
// const outputUri = 'gs://mybucket/out/'
const features = [
{type: 'DOCUMENT_LABEL_DETECTION'},
{type: 'DOCUMENT_TEXT_DETECTION'},
{type: 'DOCUMENT_IMAGE_DETECTION'},
async function main(gcsSourceUri) {
// [START vision_batch_annotate_files_gcs_beta]
// Imports the Google Cloud client libraries
const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1;
// Creates a client
const client = new ImageAnnotatorClient();
/**
* TODO(developer): Uncomment the following line before running the sample.
*/
// GCS path where the pdf file resides
// const gcsSourceUri = 'gs://my-bucket/my_pdf.pdf';
const inputConfig = {
// Supported mime_types are: 'application/pdf' and 'image/tiff'
mimeType: 'application/pdf',
gcsSource: {
uri: gcsSourceUri,
},