Hallo,
i don't anderstend. Your picker (^0.20.0) worked well on VW (Genomotion), but when i start app on Device (OnePlus One, CM13, Andriod 6.0.1) i can't to upload pictures from Camera. I found only one difference:
on vm: fileSize:6249
on device: fileSize:0
i think this is the problem or not??
my options:
const options = {
storageOptions: {
skipBackup: true,
path: 'images'
},
allowsEditing: false
};
response on device:
fileName: "image-81d70921-110b-44f6-8f46-056e2adbd5b4.jpg",
fileSize: 0,
path: "/storage/emulated/0/Pictures/image-81d70921-110b-44f6-8f46-056e2adbd5b4.jpg",
type: "image/jpeg",
uri: "file:///storage/emulated/0/Pictures/image-81d70921-110b-44f6-8f46-056e2adbd5b4.jpg"
I updated picker to the v0.20.1., but on device still not working. Please, any ideas?
It means that the image is empty.
Make sure you have the correct read/write access to device storage.
In my AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
and in response i see image height and weigh.
and i see this file "file:///storage/emulated/0/Pictures/image-81d70921-110b-44f6-8f46-056e2adbd5b4.jpg" on my device.
Try to add noData: false in your options.
And look if you have anything in the data response
ok thanks. i'll try it tomorrow.
Hallo yfuks
I tried your solution, and this is result:
with noData = true
fileName:"image-b12440ca-28fb-465e-bfc0-972d37e3192a.jpg"
fileSize:0
height:3120
isVertical:true
path:"/storage/emulated/0/Pictures/image-b12440ca-28fb-465e-bfc0-972d37e3192a.jpg"
timestamp:"2016-07-08T07:04:34Z"
type:"image/jpeg"
uri:"file:///storage/emulated/0/Pictures/image-b12440ca-28fb-465e-bfc0-972d37e3192a.jpg"
width:4160
with noData = false
data:"many symbols"
fileName:"image-f2303ab0-a82c-4754-a93a-6899e6253951.jpg"
fileSize:0
height:4160
isVertical:true
path:"/storage/emulated/0/Pictures/image-f2303ab0-a82c-4754-a93a-6899e6253951.jpg"
timestamp:"2016-07-08T06:44:40Z"
type:"image/jpeg"
uri:"file:///storage/emulated/0/Pictures/image-f2303ab0-a82c-4754-a93a-6899e6253951.jpg"
width:3120
this result only if i use Camera.
When i use image library it's all right and file uploading is done:
fileName:"IMG_20160708_081310.jpg"
fileSize:1209867
height:4160
isVertical:true
path:"/storage/emulated/0/DCIM/Camera/IMG_20160708_081310.jpg"
timestamp:"2016-07-08T06:13:10Z"
type:"image/jpeg"
uri:"content://media/external/images/media/20084"
width:3120
I don't understand why this is possible only when run it on device. Do you have an idia?
I tested all day and i have only one idea for that: my device had an empty file size response, because file is not write on card. I checked it on device in file properties and saw that file was created 2016-07-08 14:35:23 but in response from picker timestamp is 2016-07-08T14:35:22Z. And when i use Genymotion the timestamp is equal. May be this is a trouble, how do you think?
Hi guys, I am facing same issue here.
@zvat have you figure it out?
By the way, I am using Andriod 6.0.0 on MI 5
Hi @karkb, no it's not worked for me on my OnePlus One, CM13, Andriod 6.0.1.
@zvat I have tested it on Nexus 6P - 6.0.1 and its working fine, but it still does not work on MI Android 6.0.0.
Any idea ?
@karkb, I don't have any other devices to test it.
Yesterday, i tested my app on :
I don't have any idea why this picker don't want working with launchCamera. I think that the problem is: the launchCamera response is faster than file is created on device. One time had response with not NULL fileSize value, but that was only one time.
PLEASE, can anybody help me with this??? Maybe Developers have a solution???
Hi @zvat, I have tested on Nexus 6P - 6.0.1 and its working fine.
For MI Android 6.0.0. its working also when I turn off allowEditing option.
@zvat Try to play around with your phone permission settings to access camera folder.
Hi @karkb, i cheked all permissions on device and in my apk - it's all right. allowEditing option is off.
That's my launchCamera options:
const options = {
storageOptions: {
skipBackup: true
},
allowsEditing: false,
noData: true
};
we having the same problem with camera and read/write access to device storage.
attached android version info

Hi,
I too have the same issue It's not working in android 6.0.0
Please help me..
Experiencing this too. running on a OnePlus Two.
Android: 6.0.1
OxygenOS 3.0.2
"react": "^15.3.0",
"react-native": "^0.33.0",
"react-native-image-picker": "^0.22.7",
I don't know how to fix this or move forward with it...would love a pull request.
I've experienced the same issue with a OnePlus 3, and running some experiments with react-native-fs indicates that it takes around 8 seconds for the reported file size to go from 0 to the correct value, and trying to use the image in the interim (like posting it to a service via fetch) will fail.
Whilst the delay seems very long (post-processing?), it could be mitigated with an effective waitUntilSaved, but I can't get this option to work for me, so I just have to add an arbitrary delay or keep checking every second or so.
@marcshilling I think this is the root of the problem, but I'm afraid I don't have the Java skills to provide a PR which updates waitUntilSaved to delay the callback until the file has a size > 0. I hope this is helpful though.
@richsilv waitUntilSaved is only supported on iOS at the moment, so that explains why it's not working for you. I think you're probably on to something there though.
@richsilv same problem I was seeing. The uri returned in the response does not actually contain anything for somewhere between 500ms and 10s.
I'm not sure how to fix but I did find a (very hacky) workaround that may work for some people. Sadly it's all in JS:
something like...
class ImagePickerComponent extends React.Component {
constructor(props) {
super(props);
this.imageCheckInterval = null;
this.state = {imagePath: null};
}
componentWillUnmount() {
if (!_.isUndefined(this.imageCheckInterval)) {
clearInterval(this.imageCheckInterval);
}
}
openImagePicker() {
ImagePicker.showImagePicker(options, (response) => {
const CHECK_IMAGE_URI_INTERVAL_MS = 1000;
if (Platform.OS === 'ios') {
this.setState({imagePath: response.uri});
} else {
this.imageCheckInterval = setInterval( () => {
// Use getSize as a proxy for when the image exists
Image.getSize(
response.uri,
() => {
clearInterval(this.imageCheckInterval);
this.setState({imagePath: response.uri});
}
);
}, CHECK_IMAGE_URI_INTERVAL_MS);
}
});
}
render() {
if (this.state.imagePath) {
return <Image source={{uri: this.state.imagePath}} />
} else {
return <View style={styles.placeholder} />
}
}
}
Can someone confirm if this is still happening in the latest version on npm? There was a big Android rewrite recently.
@marcshilling I am unable to reproduce this error with the newest version 0.26.2 and RN 0.42. I tried on a LG G4 with Android 6, and a Samsung Galaxy S4 on Android 5
@marcshilling it's still has a problem with the filesize 0
I have checked in mi note 4(6.0) and redmi 2(4.4) it hs issue and its a issue with mi compare to the android os version because i checked geny emulator of moto 4.4 it worked fine
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.
Most helpful comment
I've experienced the same issue with a OnePlus 3, and running some experiments with react-native-fs indicates that it takes around 8 seconds for the reported file size to go from 0 to the correct value, and trying to use the image in the interim (like posting it to a service via
fetch) will fail.Whilst the delay seems very long (post-processing?), it could be mitigated with an effective
waitUntilSaved, but I can't get this option to work for me, so I just have to add an arbitrary delay or keep checking every second or so.@marcshilling I think this is the root of the problem, but I'm afraid I don't have the Java skills to provide a PR which updates
waitUntilSavedto delay the callback until the file has a size > 0. I hope this is helpful though.