From 2b4de89aaf13329ef4c7eb78c7328b91ca745cec Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 11 Aug 2013 20:49:18 -0400 Subject: [PATCH] Add Zotero.File.getContentsFromURLAsync(url) for local text files --- chrome/content/zotero/xpcom/file.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 9ad7eec4e6..bc89bb68e8 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -216,6 +216,17 @@ Zotero.File = new function(){ } + /* + * Return a promise for the contents of a URL as a string + */ + this.getContentsFromURLAsync = function (url) { + return Zotero.HTTP.promise("GET", url, { responseType: "text" }) + .then(function (xmlhttp) { + return xmlhttp.response; + }); + } + + /* * Write string to a file, overwriting existing file if necessary */