Titanium:从 Android 的 Camera/Gallery 图像本地保存文件
Titanium: Saving file locally from Android's Camera/Gallery image
我在将图像保存到 Titanium 中的本地应用程序文件时遇到问题。
专门从 event.media;
创建文件
function handleImageEvent(event) {
imgpreview.image = event.media;
var imaget = event.media;
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,imagename);
f.write(imaget);
}
//imagename : I am using in the format of 'photo0.png'
这是我到目前为止的代码,我试图通过自己的搜索将它们放在一起并进行测试,
他们不工作。抛出异常
[WARN] : TextView: TextView does not support text selection. Action mode cancelled.
[ERROR] : TiFileProxy: (KrollRuntimeThread) [5233,84017] IOException encountered
[ERROR] : TiFileProxy: java.io.IOException: read only
[ERROR] : TiFileProxy: at org.appcelerator.titanium.io.TiResourceFile.write(TiResourceFile.java:100)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.TiFileProxy.write(TiFileProxy.java:286)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:884)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1107)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347)
[ERROR] : TiFileProxy: at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] : TiFileProxy: at android.os.Looper.loop(Looper.java:137)
[错误]:TiFileProxy:在 org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
我希望我能提供更多细节,但我迷路了,抱歉
提前致谢。
Titanium.Filesystem.resourcesDirectory
是只读的。请在 http://docs.appcelerator.com/titanium/latest/#!/guide/Filesystem_Access_and_Storage-section-29004902_FilesystemAccessandStorage-Storagelocations
找到所有位置的列表,包括访问权限
我在将图像保存到 Titanium 中的本地应用程序文件时遇到问题。 专门从 event.media;
创建文件function handleImageEvent(event) {
imgpreview.image = event.media;
var imaget = event.media;
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,imagename);
f.write(imaget);
}
//imagename : I am using in the format of 'photo0.png'
这是我到目前为止的代码,我试图通过自己的搜索将它们放在一起并进行测试, 他们不工作。抛出异常
[WARN] : TextView: TextView does not support text selection. Action mode cancelled.
[ERROR] : TiFileProxy: (KrollRuntimeThread) [5233,84017] IOException encountered
[ERROR] : TiFileProxy: java.io.IOException: read only
[ERROR] : TiFileProxy: at org.appcelerator.titanium.io.TiResourceFile.write(TiResourceFile.java:100)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.TiFileProxy.write(TiFileProxy.java:286)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:884)
[ERROR] : TiFileProxy: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1107)
[ERROR] : TiFileProxy: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347)
[ERROR] : TiFileProxy: at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] : TiFileProxy: at android.os.Looper.loop(Looper.java:137)
[错误]:TiFileProxy:在 org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
我希望我能提供更多细节,但我迷路了,抱歉 提前致谢。
Titanium.Filesystem.resourcesDirectory
是只读的。请在 http://docs.appcelerator.com/titanium/latest/#!/guide/Filesystem_Access_and_Storage-section-29004902_FilesystemAccessandStorage-Storagelocations