Hi Tobias,
Well what is do is even more primitive -- I put the applet on a page that has
to pass the j_spring_auth login and then I from the applet I get the browser
cookie. Everything works fine now, it has to do with mime types when POSTing
files. Here's what worked for me if anyone goes on doing something similar:
MultipartEntity entity = new MultipartEntity();
entity.addPart("file", new InputStreamBody(new FileInputStream(tF),
tF.getName()));
HttpPost post = new HttpPost(url);
post.setEntity(entity);
post.setHeader("Cookie", "JSESSIONID=" + cookie); // this I get from the
browser with other code
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post);
String html = EntityUtils.toString(response.getEntity());
I am using the apache HTTP library.
Regards,
Biser
>Hi Biser,
>
>are you using digest authentiation? If you are running your applet against a
standard Matterhorn core, then most of the REST endpoints will be protected by
Digest authentication (etc/config.properties contains username and password).
>
>Tobias
>
>On 07.08.2012, at 11:53, Biser Milanov wrote:
>
>> Hello,
>>
>> I want add a file to the working file repository and I am using the POST
/file/mediapackage/mp-id/catalog-id with filename (the third from last) in the
rest endpoint docs. Testing from the rest endpoint docs page works -- I can
upload files. But it fails when I do it from a Java applet. Here is the code:
>>
>> Connection.Response res =
Jsoup.connect("http://myserver:8080/files/mediapackage/[some existing
mp-id here]/catalog-17").cookie("JSESSIONID",
cookie).data("file", [string with
catalog]).method(Method.POST).execute();
>>
>> I get an exception with an http error 400. Is there something in the
header I am not supplying? Or maybe the
"/mediapackage/mp-id/catalog-id" should be passed as data?
>>
>> Regards,
>> Biser
>> _______________________________________________
>> Matterhorn-users mailing list
>> [email protected]
>> http://lists.opencastproject.org/mailman/listinfo/matterhorn-users
-----------------------------------------------------------------
Гражданска отговорност – Цените на компаниите
http://www.sdi.bg/onlineInsurance/?utm_source=gbg&utm_medium=txtLink&utm_content=home
_______________________________________________
Matterhorn-users mailing list
[email protected]
http://lists.opencastproject.org/mailman/listinfo/matterhorn-users