Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ultradox GET parameters
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
public class DownloadGET {
public static void main(String[] args) throws Exception {
URL url = new URL(
"http://www.ultradox.com/ultradoc/execute?id=JaFxzA9G0ac4Npx83lvY78M9kO5lNO&action=DOWNLOAD"
+ "&position=Sales%20Representative&dateOfInterview=2013-01-31&refused=true");
InputStream inputStream = url.openStream();
FileOutputStream outputStream = new FileOutputStream(new File(
"processed.pdf"));
transfer(inputStream, outputStream);
}
private static void transfer(InputStream inputStream,
OutputStream outputStream) throws IOException {
byte[] buffer = new byte[1024];
int len;
while ((len = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, len);
}
}
}
import static com.google.appengine.api.urlfetch.FetchOptions.Builder.withDefaults;
import java.io.IOException;
import java.net.URL;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.urlfetch.HTTPMethod;
import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
@SuppressWarnings("serial")
public class App_Engine_SandboxServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
URL url = new URL(
"http://www.ultradox.com/ultradoc/execute?id=JaFxzA9G0ac4Npx83lvY78M9kO5lNO&action=DOWNLOAD"
+ "&position=Sales%20Representative&dateOfInterview=2013-01-31&refused=true");
HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET, withDefaults().setDeadline(30.0));
HTTPResponse response = urlFetchService.fetch(request);
resp.setContentType("application/pdf");
resp.getOutputStream().write(response.getContent());
}
}
function getParameters() {
var response = UrlFetchApp.fetch('http://www.ultradox.com/ultradoc/execute?id=JaFxzA9G0ac4Npx83lvY78M9kO5lNO&action=DOWNLOAD&position=Sales%20Representative&dateOfInterview=2013-01-31&refused=true');
var blob = response.getBlob();
var code = response.getResponseCode();
Logger.log(code === 200 ? "Success" : "Error Code: " + code);
// sending out email just for demo purposes
// in real applications send out personalized emails using Ultradox instead
GmailApp.sendEmail("oliver.zeigermann@gmail.com", "Your generated document", "See attachment",
{ attachments: [
{fileName: blob.getName(), mimeType: "application/pdf", content: blob.getBytes()}
]
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.