Signature Widget

1
Hello, I am using the Signature Widget for a delivery app, The Signature Widget is an String attribute with unlimited length, It is storing the Signature as an Base 64 encoded PNG Image, Question 1. How can we retrieve the image? ( we are trying to retrieve the image back into a file/ image ) 2. Can we store it as an image on a remote location on our network and store a pointer to the file in the actual table? (Storing 3000 Signatures per day – in Base64 PNG image format will fill up the Mendix local server in no time) 3. Can you show us some examples project which I can download and check? Please let me know, Thanks in advance Amrut Get the following error while implementing base64to image java action, any suggestions? An error has occurred while handling the request. [User '80' with roles 'Driver'] la: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: Java action was not implemented at {} at Orders.CreateandExportSign (JavaAction : 'Call 'Base64DecodeToFile'') at Orders.CompletePickupRequest (SubMicroflow : 'Call 'CreateandExportSign'') Advanced stacktrace: at mg.a(SourceFile:188) Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: Java action was not implemented at com.mendix.core.Core.execute(SourceFile:225) Caused by: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: Java action was not implemented at hC.b(SourceFile:194) Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: Java action was not implemented at integration.actions.Base64DecodeToFile.executeAction(Base64DecodeToFile.java:39) at integration.actions.Base64DecodeToFile.executeAction(Base64DecodeToFile.java:20) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:183) at com.mendix.core.Core.execute(SourceFile:219) at lh.a(SourceFile:69) at mg.a(SourceFile:73) at mf.executeAction(SourceFile:101) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:183) at com.mendix.core.Core.executeSync(SourceFile:196) at li.a(SourceFile:70) at mg.a(SourceFile:73) at mf.executeAction(SourceFile:101) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:183) at com.mendix.core.Core.execute(SourceFile:219) at gm.execute(SourceFile:186) at iW.a(SourceFile:304) at com.mendix.externalinterface.connector.RequestDispatching$Worker.a(SourceFile:148) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.a(SourceFile:140) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.apply(SourceFile:138) at akka.actor.Actor$class.apply(Actor.scala:545) at com.mendix.externalinterface.connector.RequestDispatching$Worker.apply(SourceFile:134) at akka.actor.LocalActorRef.invoke(ActorRef.scala:910) at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123) at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:195) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:123) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192)
asked
2 answers
3

Converting your base 64 string to an image can be don as followed:

  • Remove the leading 22 characters: who contains the "data:image/png;base64,"
  • You can use the community commons 'base64DecodeToFile' but it will not generate a thumbnail.
  • Or create your own base64DecodeToImage action with the parameters TargetImage; base64encoded; thumbnailHight; thumbnailWidth;

        // BEGIN USER CODE
    IContext context = this.getContext();
    if (this.TargetImage == null)
        throw new IllegalArgumentException("Target Image file is null");
    if (this.base64encoded == null)
        throw new IllegalArgumentException("base64 encoded  string is null");
    if (this.thumbnailHight == null)
        throw new IllegalArgumentException("thumbnail Hight is null");
    if (this.thumbnailWidth == null)
        throw new IllegalArgumentException("Thumbnail Width is null");
    byte [] decoded = org.apache.commons.codec.binary.Base64.decodeBase64(this.base64encoded.getBytes());
    Core.storeImageDocumentContent(context, this.TargetImage.getMendixObject(), new ByteArrayInputStream(decoded), this.thumbnailWidth.intValue(), this.thumbnailHight.intValue());
    return true;
    // END USER CODE
    
answered
2

you can use the community commons module from the appstore to create an image from a base 64 encoded string.

Mendix already creates a pointer to any file on a location (files directory from config) which is accessible for mendix. You can store the attachment on a network share but you won't be able to use the image within your application. If you want to use the image within your application you need to use the mendix files location (adding additional diskspace might be necessary)

answered