class FileService extends BasicService implements OwnerAPISupport<File> {

	@POST
	@Path("/screenkey/{key}")
	public Response uploadScreenshot(@PathParam("key") String key) {
		Screen existingScreen = ScreenDAO.getScreenByKey(key);
		if (existingScreen == null) {
			throwNotFound();
		}

		boolean uploadFile = false;

		// check if enough delay passed already, to not capture screens right while they
		// are loading
		if (existingScreen.isScreenshotMode() && existingScreen.getMetric_playlistTime() > 10) {
			long pageId = existingScreen.getMetric_currentPageId();
			Page existingPage = getExistingPage(pageId, false);

			if (existingPage != null) {
				uploadFile = true;

				File existingFile = doUploadScreenshot(key + "_" + pageId + "_auto", "int_screenshot_" + pageId + "_",
						Consts.xDim, Consts.yDim);

				existingPage.setAutoScreenshot(existingFile);
				PageDAO.save(existingPage);
			}
		}

		if (!uploadFile) {
			doUploadScreenshot(key, "int_screenshot_", 1280, 720);

			Date eventDate = new Date();
			existingScreen.setLastContainerAlive(eventDate);
			existingScreen = ScreenDAO.save(existingScreen);
			EventHistoryDAO.save(new EventHistory(existingScreen.getId(), eventDate));
		}

		return RESPONSE_OK;
	}

}