question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not getting anything from the file path returned on Android.

See original GitHub issue

The result I get from the PictureTakenHandler, when on Android, looks like /data/data/com.myAppName/files/camerapreview_09_02_2016_1152_04_preview.jpg

From what I understand, that looks correct. However, when I try to simply use that path as the src attribute in an tag, I just get a broken image like maybe there is no file there.

Any idea why this may be happening? Does that path look correct? Might it be failing to actually store the picture there?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
troybergcommented, Feb 16, 2016

@Djagu Yes I have. Sorry. I should have posted back much sooner, but I had forgotten I posted here. I still haven’t been able get a path that I could use directly in an 's src attribute, but my ultimate goal was to get the file’s base64 for database storage, which works as a src attribute as well, so hopefully this helps you too.

resolveLocalFileSystemURL('file:///'+result[1], function(fileEntry) {
    fileEntry.file(function(file) {
        var reader = new FileReader();
        reader.onload = function(event) {
                base64 = event.target.result; //Here is your base64 string
        };
            reader.readAsDataURL(file);
    });
});

After digging around a few different places, this is what my code looks like. Maybe you will understand what is going on here more than I do in order to better use it to fit your purposes. Unfortunately, I still don’t have a very firm grasp on handling files with JavaScript, but this got me the base64 data that I needed.

**Important Note: You need to append “file:///” to the beginning of your result in order for resolveLocalFileSystemURL() to work.

I hope that this helps.

0reactions
eeerrrtttycommented, May 22, 2019

what is the result[1] ??

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failing to get actual file path from storage in android
I suggest you get the file content using ContentResolver , copy it to a temp file in the cache, and then upload that...
Read more >
itinance/react-native-fs - GitHub
Check in the Android assets folder if the item exists. filepath is the relative path from the root of the assets folder. If...
Read more >
Path Operations - Essential Java Classes - Oracle Help Center
If the Path contains any redundant elements, it returns a path with those elements removed. This method throws an exception if the file...
Read more >
Path | Android Developers
Returns true if the path is empty (contains no lines or curves) ... Clear any lines and curves from the path, making it...
Read more >
Java File Path, Absolute Path and Canonical Path | DigitalOcean
getPath() : This file path method returns the abstract pathname as String. ... directory of the drive named by the pathname, if any;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found