public boolean fileWasUploadedBefore(String spaceName, String pageName, String fileName) {
		if (downloadedPage == null || !downloadedPage.equals(pageName)) {
			boolean exist = false;
			fileNames = new ArrayList<String>();
			downloadedPage = pageName;
			if (pageName.equals(""))
				pageName = "Home";

			pageName = pageName.replaceAll("\\s", "+");
			pageName = pageName.replaceAll("&", "%26");

			String url = server + "rest/api/content?title=" + pageName + "&spaceKey=" + spaceName
					+ "&expand=descendants";
			JSONObject mainJson = downloadJSON(url, credentials);
			JSONArray array = (JSONArray) mainJson.getJSONArray("results");
			JSONObject result = array.getJSONObject(0);

			JSONObject desc = result.getJSONObject("descendants");
			JSONObject links = desc.getJSONObject("_links");
			String descUrl = links.getString("self");

			JSONObject attachmentsMainJson = downloadJSON(descUrl + "?expand=attachment",
					credentials);
			JSONObject attachment = attachmentsMainJson.getJSONObject("attachment");

			JSONObject links2 = attachment.getJSONObject("_links");
			String descUrl2 = links2.getString("self");

			JSONObject attachmentsMainJson2 = downloadJSON(descUrl2 + "?limit=300", credentials);
			JSONArray attachmentArray = attachmentsMainJson2.getJSONArray("results");

			Iterator i = attachmentArray.iterator();
			while (i.hasNext()) {

				JSONObject singleAttachment = (JSONObject) i.next();
				String title = singleAttachment.getString("title");
				fileNames.add(title);
				if (fileName.equals(title)) {
					exist = true;
				}
			}
			if (!exist)
				downloadedPage = null;
			return exist;
		} else {
			if (fileNames.contains(fileName))
				return true;
		}
		downloadedPage = null;
		return false;
	}