Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying failed java.io.FileNotFoundException #666

Open
lantah-1 opened this issue Jun 4, 2020 · 2 comments
Open

Copying failed java.io.FileNotFoundException #666

lantah-1 opened this issue Jun 4, 2020 · 2 comments

Comments

@lantah-1
Copy link

lantah-1 commented Jun 4, 2020

Copying failed with FileNotFoundException.

Android 10 , oneplus 6.

** outputStream = new FileOutputStream(new File(outputUri.getPath())); **

can not use new File with path to create FileOutputStream on Android 10.

E/BitmapWorkerTask: Copying failed java.io.FileNotFoundException: /external/images/media/5184: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:496) at java.io.FileOutputStream.<init>(FileOutputStream.java:235) at java.io.FileOutputStream.<init>(FileOutputStream.java:186) at com.yalantis.ucrop.task.BitmapLoadTask.copyFile(BitmapLoadTask.java:177) at com.yalantis.ucrop.task.BitmapLoadTask.processInputUri(BitmapLoadTask.java:155) at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:85) at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:36) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Linux.open(Native Method) at libcore.io.ForwardingOs.open(ForwardingOs.java:167) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252) at libcore.io.ForwardingOs.open(ForwardingOs.java:167) at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7581) at libcore.io.IoBridge.open(IoBridge.java:482) at java.io.FileOutputStream.<init>(FileOutputStream.java:235)  at java.io.FileOutputStream.<init>(FileOutputStream.java:186)  at com.yalantis.ucrop.task.BitmapLoadTask.copyFile(BitmapLoadTask.java:177)  at com.yalantis.ucrop.task.BitmapLoadTask.processInputUri(BitmapLoadTask.java:155)  at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:85)  at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:36)  at android.os.AsyncTask$3.call(AsyncTask.java:378)  at java.util.concurrent.FutureTask.run(FutureTask.java:266)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:919) 

@lantah-1
Copy link
Author

lantah-1 commented Jun 4, 2020

`public static void copyFile(@nonnull String pathFrom, @nonnull String pathTo) throws IOException {
if (pathFrom.equalsIgnoreCase(pathTo)) {
return;
}

    FileChannel outputChannel = null;
    FileChannel inputChannel = null;
    try {
        inputChannel = new FileInputStream(new File(pathFrom)).getChannel();
        outputChannel = new FileOutputStream(new File(pathTo)).getChannel();
        inputChannel.transferTo(0, inputChannel.size(), outputChannel);
        inputChannel.close();
    } finally {
        if (inputChannel != null) inputChannel.close();
        if (outputChannel != null) outputChannel.close();
    }
}`

if filepath is on public directory or other who not is app-specific directory , can not use new file api to create a file.

@fabio-blanco
Copy link

The same problem that is the root of the issue #668

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants