java - No such file or directory found, image path to file -
i have nexus 5 android 5.0. want send image amazon s3 error:
11-27 11:29:52.687 21423-21423/com.laurenswuyts.witpa e/upload amazons3﹕ com.amazonaws.amazonclientexception: unable calculate md5 hash: /document/image:2810: open failed: enoent (no such file or directory) @ com.amazonaws.services.s3.amazons3client.putobject(unknown source) @ com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadcallable.uploadinonechunk(unknown source) @ com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadcallable.call(unknown source) @ com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.upload(unknown source) @ com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.call(unknown source) @ com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.call(unknown source) @ java.util.concurrent.futuretask.run(futuretask.java:237) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) @ java.lang.thread.run(thread.java:818) caused by: java.io.filenotfoundexception: /document/image:2810: open failed: enoent (no such file or directory) @ libcore.io.iobridge.open(iobridge.java:456) @ java.io.fileinputstream.<init>(fileinputstream.java:76) @ com.amazonaws.util.md5utils.computemd5hash(unknown source) @ com.amazonaws.util.md5utils.md5asbase64(unknown source) at com.amazonaws.services.s3.amazons3client.putobject(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadcallable.uploadinonechunk(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadcallable.call(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.upload(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.call(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.call(unknown source) at java.util.concurrent.futuretask.run(futuretask.java:237) at java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) at java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) at java.lang.thread.run(thread.java:818) caused by: android.system.errnoexception: open failed: enoent (no such file or directory) @ libcore.io.posix.open(native method) @ libcore.io.blockguardos.open(blockguardos.java:186) @ libcore.io.iobridge.open(iobridge.java:442) at java.io.fileinputstream.<init>(fileinputstream.java:76) at com.amazonaws.util.md5utils.computemd5hash(unknown source) at com.amazonaws.util.md5utils.md5asbase64(unknown source) at com.amazonaws.services.s3.amazons3client.putobject(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadcallable.uploadinonechunk(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadcallable.call(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.upload(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.call(unknown source) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.uploadmonitor.call(unknown source) at java.util.concurrent.futuretask.run(futuretask.java:237) at java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) at java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) at java.lang.thread.run(thread.java:818)
so have button can select image phone:
//when clicked on addimage addimage.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // open gallery browser intent intent = new intent(); intent.settype("image/*"); intent.setaction(intent.action_get_content); startactivityforresult(intent.createchooser(intent, "select picture"), pick_image); } }); @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (requestcode == pick_image && resultcode == activity.result_ok && null != data) { uri = data.getdata(); //create file of image upload images3 = new file(uri.getpath()); } }
i error @ line = images3 = new file(uri.getpath());
to full code of upload amazon s3:
transfermanager transfermanager = new transfermanager(credentialsprovider); try { mupload = transfermanager.upload( "witpalol", "image.jpg", images3); mupload.waitforcompletion(); } catch (exception e) { log.e("upload amazons3", "", e); }
but problem can't file ... have solution this?
edit
i tried full path of uri:
// , convert image uri direct file system path of image file public string getrealpathfromuri(uri contenturi) { // can post image string [] proj={mediastore.images.media.data}; cursor cursor = getactivity().getcontentresolver().query(contenturi, proj, // columns return null, // clause; rows return (all rows) null, // clause selection arguments (none) null); // order-by clause (ascending name) int column_index = cursor.getcolumnindexorthrow(mediastore.images.media.data); cursor.movetofirst(); return cursor.getstring(column_index); }
so images3 = new file(getrealpathfromuri(uri));
but error on line:
11-27 11:55:18.872 23286-23286/com.laurenswuyts.witpa e/androidruntime﹕ fatal exception: main process: com.laurenswuyts.witpa, pid: 23286 java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=65537, result=-1, data=intent { dat=content://com.android.providers.media.documents/document/image:2810 flg=0x1 }} activity {com.laurenswuyts.witpa/com.laurenswuyts.witpa.activities.events.addeventactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'char[] java.lang.string.tochararray()' on null object reference @ android.app.activitythread.deliverresults(activitythread.java:3539) @ android.app.activitythread.handlesendresult(activitythread.java:3582) @ android.app.activitythread.access$1300(activitythread.java:144) @ android.app.activitythread$h.handlemessage(activitythread.java:1327) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5221) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694) caused by: java.lang.nullpointerexception: attempt invoke virtual method 'char[] java.lang.string.tochararray()' on null object reference @ java.io.file.fixslashes(file.java:185) @ java.io.file.<init>(file.java:134) @ com.laurenswuyts.witpa.fragments.events.addeventfragment.decodeuri(addeventfragment.java:254) @ com.laurenswuyts.witpa.fragments.events.addeventfragment.onactivityresult(addeventfragment.java:213) @ android.support.v4.app.fragmentactivity.onactivityresult(fragmentactivity.java:163) @ android.app.activity.dispatchactivityresult(activity.java:6135) @ android.app.activitythread.deliverresults(activitythread.java:3535) at android.app.activitythread.handlesendresult(activitythread.java:3582) at android.app.activitythread.access$1300(activitythread.java:144) at android.app.activitythread$h.handlemessage(activitythread.java:1327) at android.os.handler.dispatchmessage(handler.java:102) at android.os.looper.loop(looper.java:135) at android.app.activitythread.main(activitythread.java:5221) at java.lang.reflect.method.invoke(native method) at java.lang.reflect.method.invoke(method.java:372) at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) at com.android.internal.os.zygoteinit.main(zygoteinit.java:694)
Comments
Post a Comment