So we've got a button that opens the photo gallery.
photogallerybutton.addEventListener("click", function(e) { Titanium.Media.openPhotoGallery({ success : function(e) { // called when media returned from the camera Ti.API.debug('Our type was: ' + e.mediaType); if (e.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { photo.image = e.media; } etc, etc, etcThen we've got the send code
var upload = Ti.Network.createHTTPClient(); upload.send({ photo : photo.image, });Now, all this code is working for my camera selections but when I attempt to upload a photo gallery selection, I get this:
[WARN] : W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference [WARN] : W/System.err: at java.io.File.fixSlashes(File.java:185) [WARN] : W/System.err: at java.io.File.<init>(File.java:134) [WARN] : W/System.err: at org.appcelerator.titanium.io.TitaniumBlob.getFile(TitaniumBlob.java:77) [WARN] : W/System.err: at org.appcelerator.titanium.TiBlob.getLength(TiBlob.java:315) [WARN] : W/System.err: at org.appcelerator.titanium.TiBlob.getBytes(TiBlob.java:278) [WARN] : W/System.err: at ti.modules.titanium.network.TiHTTPClient.addTitaniumFileAsPostData(TiHTTPClient.java:1003) [WARN] : W/System.err: at ti.modules.titanium.network.TiHTTPClient.send(TiHTTPClient.java:1181) [WARN] : W/System.err: at ti.modules.titanium.network.HTTPClientProxy.send(HTTPClientProxy.java:132) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) [ERROR] : TiExceptionHandler: (main) [572494,572726] ----- Titanium Javascript Runtime Error ----- [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62) [WARN] : W/System.err: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:884) [WARN] : W/System.err: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1107) [WARN] : W/System.err: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347) [ERROR] : TiExceptionHandler: (main) [0,572726] - In ti:/httpclient.js:28,9 [WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiExceptionHandler: (main) [1,572727] - Message: Uncaught Error: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference [ERROR] : TiExceptionHandler: (main) [0,572727] - Source: _send.call(this, options); [ERROR] : V8Exception: Exception occurred at ti:/httpclient.js:28: Uncaught Error: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference [WARN] : W/System.err: at android.os.Looper.loop(Looper.java:135) [WARN] : W/System.err: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)A nice fat nullpointer.
Again, I have the same imageview responsible for an image upload which uses the same code. What's different? Everywhere I've checked stipulates the photogallery image, when applied to an imageview.image is a blob all the same and the kitchen sink example doesn't demonstrate any different.
What am I missing?