Пример #1
0
var assertUrlExists = function(url) {
  var urlstr = url.toString();
  rest.head(urlstr).on('complete', function(result) {
    if (result instanceof Error) {
      console.log("Error: url %s not found (%s). Exiting.", urlstr, result.message);
      process.exit(1);
    }
  });
  return urlstr;
};
Пример #2
0
var assertUrlExists = function(inurl) {
    var deferred = q.defer();
    rest.head(inurl).on('complete', function(result, response) {
      if (result instanceof Error) {
        console.log("%s does not exist. Exiting.", inurl);
        process.exit(1); // http://nodejs.org/api/process.html#process_process_exit_code
      } else {
        deferred.resolve(result);
      }
    });
    return inurl;
}
Пример #3
0
var assertUrlExists = function(inUrl, callbackSuccess) {
  var instr = inUrl.toString();
  rest.head(instr).on('complete', function(result,response) {
    if (response.statusCode == 200) {
      callbackSuccess(instr);
    }
    else {
      console.log("%s does not exist. Exiting.", instr);
      process.exit(1); // http://nodejs.org/api/process.html#process_process_exit_code
    }
  });
};
Пример #4
0
var assertURLExists = function(infile) {
    var instr = infile.toString();
    console.log("url exits");
    console.log(instr);

    restler.head(instr).on('complete', function(result) {
        console.log("complete");
        if (result instanceof Error) {
            console.log("%s does not exist. Exiting.", instr);
            process.exit(1); // http://nodejs.org/api/process.html#process_process_exit_code
        }
        else
            console.log(result);
    });
    console.log("not complete");
    return instr;
};
		metaData: function(key, callback) {
			var 
				// This url should expire in one hour
				expiry 	= new Date(moment().add(1, 'hour').format()).getTime(),
			
				// Lets put together our policy
				stringPolicy = "HEAD\n" + "\n" + "\n" + expiry + "\n" + '/' + storageBucket + '/' + key,
			
				// create signature and make it url safe
				signature = encodeURIComponent(crypto.createSign('sha256').update(stringPolicy).sign(privateKey,"base64")),

				// signed url
				url = "https://" + storageBucket + ".storage.googleapis.com/" + key +"?GoogleAccessId=" + googleServicesEmail + "&Expires=" + expiry + "&Signature=" + signature;
		
			rest.head(url).on("complete", function(err, res) {
				callback(res.headers);
			});	
		
		},
Пример #6
0
		var pdf = function() {
			rest.head(url, http_options).on('complete', function(result, response) {
				if (result instanceof Error) {
					callback(result);
				} else {
					if (response.statusCode === 200) {
						var meta = parseMeta(url, _options, result);
						callback(null, meta);
					}
				}
			}).on('3XX', function(data, res) {
				redirectCount++;
				if (redirectCount > 5) {
					return callback("Too many redirects");
				}
				url = res.headers.location;
				return pdf();
			}).on('timeout', function() {
				callback('Timeout');
			});
		};