 #   HUBOT_GRAFANA_S3_SECRET_ACCESS_KEY - Optional; Secret access key for S3
 #   HUBOT_GRAFANA_S3_PREFIX - Optional; Bucket prefix (useful for shared buckets)
 #   HUBOT_GRAFANA_S3_REGION - Optional; Bucket region (defaults to us-standard)
+#   HUBOT_USE_GRAFANA_IMAGES - true|false, whether to use grafana-images
+#   HUBOT_GRAFANA_IMAGES_HOST - The host where grafana images resides, e.g. 'http://grafana.example.com'
 #
 # Dependencies:
 #   "knox": "^0.9.2"

      data = JSON.parse(body)
      return callback(data)

  # Pick a random filename
  uploadPath = () ->
    prefix = s3_prefix || 'grafana'
    "#{prefix}/#{crypto.randomBytes(20).toString('hex')}.png"

  # Fetch an image from provided URL, upload it to S3, returning the resulting URL
  fetchAndUpload = (msg, title, url, link) ->
    if grafana_api_key
        requestHeaders =
          encoding: null,


          # Fork here for S3-based upload and non-S3
          if (s3_bucket && s3_access_key && s3_secret_key)
            s3FetchAndUpload msg, title, imageUrl, link
          else if (use_grafana_images == "true")
            customFetchAndUpload msg, title, imageUrl, link
          else
            sendRobotResponse msg, title, imageUrl, link

