Giter Site home page Giter Site logo

Comments (6)

alpha0010 avatar alpha0010 commented on June 8, 2024 1

Thinking about how to implement; might be a bit tricky regarding what makes sense cross-platform.

from react-native-file-access.

alpha0010 avatar alpha0010 commented on June 8, 2024 1

Try Dirs.SDCardDir. Use it as a normal path (make subdirectories, write files, etc.). Note that it may be null/undefined if the path cannot be determined.

from react-native-file-access.

alpha0010 avatar alpha0010 commented on June 8, 2024 1

@mitchdowney Could you open a new issue with this? It makes it easier for me to track.

Have you looked around the device to see if you can find the .mp3 somewhere? https://developer.android.com/studio/debug/device-file-explorer

from react-native-file-access.

alpha0010 avatar alpha0010 commented on June 8, 2024

Two types of data apps tend to have are internal managed (database, cache, etc.) and system managed (pictures, videos, etc. that should be visible to all apps on the device). cpExternal() is intended for the later. They are system defined locations, so all apps (if granted permission) can share the media.

What would the goal of a custom directory be? No other app would know to look for it. If just trying to use folders to organize internally, something like FileSystem.mkdir(Dirs.DocumentDir + '/subfolder'), then write files to that folder.

Or am I missing your goal?

from react-native-file-access.

Marvedog avatar Marvedog commented on June 8, 2024

yeah, kinda. The purpose is not for other apps to be able to find it, but to simplify the discovery process for end-users. We use this repo to download PDFs to the end-users' external storage such that they can retrieve it and use it for whatever purpose they want. The argument is just that it may be simpler to find the document in a My-app-name folder than to dig into the downloads folder.

from react-native-file-access.

mitchdowney avatar mitchdowney commented on June 8, 2024

@alpha0010 sorry to bug you, but I struggled with scoped storage all day, and I'm wondering if you could see some obvious mistake I'm making with my process...

I'm trying to copy to the scoped storage "Podcasts" directory on an SD card, but I get an error like follows:

Error: /tree/01F6-AC3F:Podcasts/document/01F6-AC3F:Podcasts/7kJmAzNQ3.mp3: open failed: ENOENT (No such file or directory)

Here's basically the sequence of steps I'm doing to get there...

First, I requested permission to the SD card Podcasts directory using:

import * as ScopedStorage from 'react-native-scoped-storage'
...
  _setExtDownloadFileLocationAndroid10 = async () => {
    const dir = await ScopedStorage.openDocumentTree(true)

    if (dir?.uri?.endsWith('%3APodcasts')) {
      const sdCardDownloadLocation = dir.uri
      await AsyncStorage.setItem(PV.Keys.EXT_STORAGE_DLOAD_LOCATION, sdCardDownloadLocation)  
      ...
    }
  ...
}

Then, on file download using react-native-background-downloader, I download to origDestination, then try to move it into scoped storage:

  const folderPath = RNFS.TemporaryDirectoryPath
  const origDestination = `${folderPath}/${episode.id}${ext}`
  // download the episode from origDestination using react-native-background-downloader
  ...
  // then in the `done` callback, I try to move the file into scoped storage:
  const sdDestination = `${sdCardDownloadLocation}/${episode.id}.mp3`
  await FileSystem.cp(origDestination, sdDestination)
...

However...when I do that I get:

Error: /tree/01F6-AC3F:Podcasts/document/01F6-AC3F:Podcasts/7kJmAzNQ3.mp3: open failed: ENOENT (No such file or directory)

There must be something fundamental I'm missing about this process...does that make sense, and do you have any advice on how to accomplish this?

from react-native-file-access.

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.