Giter VIP home page Giter VIP logo

Comments (7)

anggrayudi avatar anggrayudi commented on June 17, 2024 1

As a temporary solution, please go ahead with copyFileTo(Context, DocumentFile, FileDescription, FileCallback):

DocumentFile source = DocumentFile.fromFile(sourceDBFile);
// Parameter requiresWriteAccess must be "true", because you're going to write files into it
DocumentFile targetFolder = DocumentFileCompat.fromFullPath(this, data.m_localImportSourcePath, DocumentFileType.ANY, true);
DocumentFileUtils.copyFileTo(source, ctx, targetFolder, null, new FileCallback());

from simplestorage.

anggrayudi avatar anggrayudi commented on June 17, 2024

You can override onParentConflict() or onContentConflict() to replace the existing folder. Read the example here:

from simplestorage.

Toprakete avatar Toprakete commented on June 17, 2024

Hi,
thx for your fast answer.
I use the copyFileTo function which does only provide a FileCallback with "onConflict", which I use to always replace the existing file
@OverRide
public void onConflict(@nonnull DocumentFile destinationFile, @nonnull FileConflictAction action) {
//super.onConflict(destinationFile, action);
// replace
action.confirmResolution(ConflictResolution.REPLACE);
}
But this i not called, because the originla file is on level up an so there's no conflict
Do you have another idea?
thx and br
Klaus

from simplestorage.

Toprakete avatar Toprakete commented on June 17, 2024

Ok, I tried to write directly in the target directory and got a permission denied, even this folder has storage access (SimpleStorage.hasStorageAccess retruns true)
The problem is that the permission is on the tree-url and not the single url, when creating DocumentFile fromFile.

It all work when I use instead of "data.m_localImportSourcePath" ("/storage/emulated/0/test") the corresponding Tree-Uri from the getPersistedUriPermissions result List
Using this, it works like exspected.

The problem is to make the Tree-Uri from the getPersistedUriPermissions list comparable with the single tree uri from the picker result. I didn't find a nice way, so I compare both last segments of the uris. no idea wether there's another better solution.

Sorry for wasting your time. Please close, if this is the wanted way to go.

br
Klaus

from simplestorage.

anggrayudi avatar anggrayudi commented on June 17, 2024

Hi, this is a bug. I'll fix it in v1.5.2

from simplestorage.

Toprakete avatar Toprakete commented on June 17, 2024

Hi,
thx so much.
br
Klaus

from simplestorage.

anggrayudi avatar anggrayudi commented on June 17, 2024

Fixed in v1.5.2

from simplestorage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.