jibon57 / nativescript-mediafilepicker

A complete file picker solution for NativeScript
Apache License 2.0
51 stars 39 forks source link

No rawData retrieved, empty. #134

Closed ouryhamdalaye closed 3 years ago

ouryhamdalaye commented 3 years ago

When I run the snippet code :

mediafilepicker.on("getFiles", function (res) {
                let results = res.object.get('results');
                console.dir(results);
});

I get an empty rawData object

0: {
  "type": "image",
  "file": "/storage/emulated/0/DCIM/Screenshots/Screenshot_20210112-195856.jpg",
  "rawData": {}
}

Platform Android version 7.0

Am I missing something here ?

profjefferson commented 3 years ago

Same here with iOS!

jerbob92 commented 3 years ago

What are you expecting to be in the rawData?

ouryhamdalaye commented 3 years ago

I was expecting the file to be there otherwise how do i get the file in order to store it ? The "file" entey in the array give me only the path to the file . Could you give us more precisions ? Thanks for your job

jerbob92 commented 3 years ago

I did not create this plugin, but looking at the code, rawData never contains the file data. If you look at the code: https://github.com/jibon57/nativescript-mediafilepicker/blob/master/src/mediafilepicker.android.ts It looks like it always contains a native java object, in some cases a java.io.File, which can be used to read the raw file data.

I would say the best way would be to load the file with NativeScript based on the path that is returned: https://docs.nativescript.org/ns-framework-modules/file-system#file-methods

ouryhamdalaye commented 3 years ago

Yes I used this way, by using filesystem I was able to load the image using File.fromPath(theimagepath).

Its a 2 step solution but there is no choice unfortunately.

Appreciated your short reply.