Map<String,String> headers = progress.source.setup();
Map<String,String> disposition = UploadSource.parseParameters(headers.get("Content-Disposition"));
String filename = disposition.get("filename");
is = progress.source.getInputStream();
Uniform client = getContext().getClientDispatcher();
//Client client = new Client(getContext().createChildContext(),appRef.getSchemeProtocol());
Request appRequest = new Request(progress.update ? Method.PUT : Method.POST,appRef);
appRequest.setRootRef(getRequest().getRootRef());
if (appUsername!=null) {
getLogger().info("Using username "+appUsername+" for authentication for APP target.");
appRequest.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,appUsername,appPassword));
} else if (getRequest().getChallengeResponse()!=null) {
// pass along authentication
getLogger().info("Passing along authentication to APP target.");
appRequest.setChallengeResponse(getRequest().getChallengeResponse());
}
Cookie cookie = getRequest().getCookies().getFirst("I");
if (cookie!=null) {
appRequest.getCookies().add(cookie);
}
// add header for slug if new upload
if (!progress.update && filename!=null) {
getLogger().info("Upload filename: "+filename);
Form appHeaders = new Form();
appHeaders.add("slug",filename);
appRequest.getAttributes().put("org.restlet.http.headers",appHeaders);
}
// setup body
appRequest.setEntity(new InputRepresentation(is,MediaType.valueOf(headers.get("Content-Type"))));
// make request
Response appResponse = new Response(appRequest);
client.handle(appRequest,appResponse);
if (appResponse.getStatus().isSuccess()) {
if (progress.update) {
progress.status = appResponse.getStatus().getCode();
} else {