Image uploading problems

0
We've been uploading pictures using the phonegap camera widget and have recently been experiencing some problems.  We keep receiving this error message, its stacktrace is below, I don't believe it is a problem with the phonegap camera widget.  In addition to this error message, we have been seeing another one that says java.lang.RuntimeException: LocalFileSystemStore:: File does not exist for key: 254240 at com.mendix.storage.localfilesystem.internal.LocalFileSystemStore.com$mendix$storage$localfilesystem$internal$LocalFileSystemStore$$getFileDocumentAsFile(LocalFileSystemStore.scala:153) If anyone could help me or point me in the right direction to look at.  This is the stacktrace of the first error message I referenced.  Thank you. Message Uploading file failed: null Stack trace java.lang.NullPointerException at com.mendix.webui.requesthandling.FileRequestHandler.doUpload(FileRequestHandler.scala:157) at com.mendix.webui.requesthandling.FileRequestHandler.handleUpload(FileRequestHandler.scala:84) at com.mendix.webui.requesthandling.FileRequestHandler.handleRequest(FileRequestHandler.scala:67) at com.mendix.webui.requesthandling.FileRequestHandler.processRequest(FileRequestHandler.scala:59) at com.mendix.externalinterface.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:69) at com.mendix.externalinterface.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:66) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36) at com.mendix.externalinterface.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.java:72) at com.mendix.core.impl.MxRuntimeImpl.processRequest(MxRuntimeImpl.java:745) at com.mendix.m2ee.appcontainer.server.handler.RuntimeHandler.handle(RuntimeHandler.java:41) at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:368) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:748)  
asked
4 answers
2

This can happen when the object does not match entity access constraints. The device will then not be able to link the uploaded file to the Mendix Object.

For example: the user may only see objects related to their account through some association to Account or User. If the app does not set the association, the object is created but cannot be seen anymore, causing this error. The same can happen when the user may only see objects with a certain enum value. Note that objects created in an offline app do not receive defaults specified in the domain model. You have to explicitly set them.

 

Edit:

If it is intermittent it may be a connection issue. I have that in an app which uses the default image uploader. The app is used on devices in the browser but is not a hybrid app. Every now and then an image upload just fails, The page uses a microflow button as save button. In the microflow I check whether the hasContents flag is set. If not, I kindly request the user to re-take the picture.

Maybe you can check in your commit microflow that is connected to the camera widget whether the image object hasContents flag is set.

 

Hope this helps.

answered
2

Monique,

Sounds like the Camera Widget may not have permission to store files on the phone.  Maybe you can test a scenario where the user hasn't granted access to the app to access local pictures and see if you get the same error.  Another idea:  maybe phone storage is full so the picture can't be saved?

Mike

answered
2

Last week I executed some tests to see the impact of the image quality setting of the camera widget. The default value for the image quality settings of height and width are set to 0. This means the image will be saved full size. 

If you choose to upload a 3024x4032 picture with size 2,03MB, then it the system needs to transfer 323,99KB over the network. However if you change the image quality to 500, then it the system needs to transfer only 4,93KB.

Given the top smartphone snappers around, these devices make awesome pictures nowadays, but in most use cases there's no need to store the full sized image in your database. So it's a best practice to limit the size of the picture.

Also please note that the description of the image quality in the read me is not correct. The image quality is used to scale the image, and not a number between 0 and 100. I have created a pull request for an update of the readme.

answered
2

The HasContents gets set by the system when the object gets stored, such as the binary file for the image. Checking it lets you know if the image actually got stored or if it got lost during a connection failure. What Marcel is suggesting is spot on. Your users are trying to upload large image files which can easily fail. Wilfried's suggestion to limit the size in your app is a very sound one if possible though we don't know the requirement of the app. If you need to store hi-res images that are large in size, I suggest designing a UX process that informs the user of the challenges and then gives them the option to sync on cellular and do the HasContents verification, or give them an option to sync when connected to WiFi only. Takes a bit of engineering but will result in a better experience for your users and app designers.

answered