Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"We can not access the URL currently."

I call google api when the return of "We can not access the URL currently." But the resources must exist and can be accessed.

https://vision.googleapis.com/v1/images:annotate

request content:

{
  "requests": [
    {
      "image": {
        "source": {
          "imageUri": "http://yun.jybdfx.com/static/img/homebg.jpg"
        }
      },
      "features": [
        {
          "type": "TEXT_DETECTION"
        }
      ],
      "imageContext": {
        "languageHints": [
          "zh"
        ]
      }
    }
  ]
}

response content:

{
  "responses": [
    {
      "error": {
        "code": 4,
        "message": "We can not access the URL currently. Please download the content and pass it in."
      }
    }
  ]
}
like image 690
wei193 Avatar asked Jul 15 '17 15:07

wei193


4 Answers

I have faced the same issue when I was trying to call the api using the firebase storage download url (although it worked initially)

After looking around I found the below example in the api docs for NodeJs.

NodeJs example

// Imports the Google Cloud client libraries
const vision = require('@google-cloud/vision');

// Creates a client
const client = new vision.ImageAnnotatorClient();

/**
 * TODO(developer): Uncomment the following lines before running the sample.
 */
// const bucketName = 'Bucket where the file resides, e.g. my-bucket';
// const fileName = 'Path to file within bucket, e.g. path/to/image.png';

// Performs text detection on the gcs file
const [result] = await client.textDetection(`gs://${bucketName}/${fileName}`);
const detections = result.textAnnotations;
console.log('Text:');
detections.forEach(text => console.log(text));
like image 98
Mazen Ebeid Avatar answered Oct 07 '22 23:10

Mazen Ebeid


As of August, 2017, this is a known issue with the Google Cloud Vision API (source). It appears to repro for some users but not deterministically, and I've run into it myself with many images.

Current workarounds include either uploading your content to Google Cloud Storage and passing its gs:// uri (note it does not have to be publicly readable on GCS) or downloading the image locally and passing it to the vision API in base64 format.

Here's an example in Node.js of the latter approach:

const request = require('request-promise-native').defaults({
  encoding: 'base64'
})

const data = await request(image)

const response = await client.annotateImage({
  image: {
    content: data
  },
  features: [
    { type: vision.v1.types.Feature.Type.LABEL_DETECTION },
    { type: vision.v1.types.Feature.Type.CROP_HINTS }
  ]
})
like image 24
fisch2 Avatar answered Oct 08 '22 00:10

fisch2


For me works only uploading image to google cloud platform and passing it to URI parameters.

like image 1
Alessandro Mattiuzzi Avatar answered Oct 07 '22 23:10

Alessandro Mattiuzzi


In my case, I tried retrieving an image used by Cloudinary our main image hosting provider.

When I accessed the same image but hosted on our secondary Rackspace powered CDN, Google OCR was able to access the image.

Not sure why Cloudinary didn't work when I was able to access the image via my web browser, but just my little workaround situation.

like image 1
Dylan Pierce Avatar answered Oct 07 '22 23:10

Dylan Pierce