Copy Image object

3
In the client browser, I've created a base library of objects (of the same type) that inherit form an image object. Next I would like choose one of the objects, copy the contents of the object (with image) into a new object, change some of the values, set a reference to another object and save the object (without changing the base library). How can I do that? Steps: In client browser: create library of 'ImageWithDescription' objects (object inherits from image). In microflow: Copy one of the 'ImageWithDescription' objects with image (how?). In microflow: Change values in new/copied 'ImageWithDescription' objects. In microflow: Set a reference in the new/copied 'ImageWithDescription' objects. In microflow: Save the niew object. Can anyone help?
asked
1 answers
1

Using a java action, it is quite trivial to copy an image with contents. This java action takes a Logo (descendant of System.Image) as argument, an returns a new one. Note that it creates a thumbnail of 60x60 as well.

public CopyLogo(IMendixObject LogoToCopy)
{
    super();
    this.LogoToCopy = LogoToCopy == null ? null : appstore.proxies.Logo.initialize(LogoToCopy);
}

@Override
public IMendixObject executeAction() throws Exception
{
    // BEGIN USER CODE
    Logo newLogo = Logo.create(this.getContext());
    newLogo.setName(this.getContext(), LogoToCopy.getName(this.getContext()));
    InputStream inputStream = Core.getFileDocumentContent(this.getContext(), LogoToCopy.getMendixObject());
    Core.storeImageDocumentContent(this.getContext(), newLogo.getMendixObject(), inputStream, 60, 60);      
    return newLogo.getMendixObject();
    // END USER CODE
}
answered