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

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();
    }
0 votes

2 answers

2146 views

ANSWER



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

-1 votes



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

0 votes