cancel
Showing results for 
Search instead for 
Did you mean: 

How do I compose the Automation Client request for Picture.Create (in 5.4.3)

neilbelford_
Confirmed Champ
Confirmed Champ

I can create a Picture document without content. I cant pass the correct string for the property "originalPicture=???" According to the fairly terse doco in org.nuxeo.ecm.automation.core.operations.services.CreatePicture.java , "???" should be a JSON encoded JPEG.

Can you tell me how to compose "???".

My (pseudo)code so far looks like this

public void createPictureExample()
{
	HttpAutomationClient client = new HttpAutomationClient( "http://localhost:8080/nuxeo/site/automation");
	Session session = client.getSession("Administrator", "Administrator");

	Document root = null;
	try {
		root = (Document) session.newRequest("Document.Fetch").set(
		        "value", "/").execute();
	} catch (Exception e) {
		e.printStackTrace();
	}

	
      File file = getThePictureToUpload();
          FileBlob fb = new FileBlob(file);
          fb.setMimeType("image/jpeg");
	
	// do something with fb here to JSON encode it
	try {
		session.newRequest("Picture.Create")
			.setInput(root)
			.set("name", "mypicture4")
			.set("properties", "originalPicture=???\ndc:title=My Picture4").execute();
	} catch (Exception e) {
		e.printStackTrace();
	}
1 ACCEPTED ANSWER

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

You have an example of how to do that here into the section "Blob upload example".

View answer in original post

2 REPLIES 2

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

You have an example of how to do that here into the section "Blob upload example".

neilbelford_
Confirmed Champ
Confirmed Champ

Answer above is correct, sorry about minus vote, cant correct it.