Comments (6)
Thinking about how to implement; might be a bit tricky regarding what makes sense cross-platform.
from react-native-file-access.
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.
@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.
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.
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.
@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)
- Android - getting error while generating apk HOT 2
- [Q] cp (FileSystem.cp) HOT 1
- Build fail on iOS after update v3.0.2, react-native 0.71.8 , expo 48 HOT 6
- Add support for reading files from resource id returned by require() HOT 2
- Add a fallback for cpAsset resource type HOT 3
- Error when calling statDir function with many files HOT 2
- Save dialog support ?
- FileSystem.cpExternal creates a invalid file if the file already access
- Download Manager support like rn-fetch-blob to enable downloads using DownloadManager for android
- [iOS] privacy-related API usage HOT 2
- Unable to find specification for `ZIPFoundation (= 0.9.11)` and `hermes-engine (~> 0.9.0)` HOT 1
- Read file from assets directory HOT 4
- fetch: Failed to connect to localhost/127.0.0.1:PORT HOT 1
- Maven problem HOT 2
- Write Blob, instead of just string HOT 2
- support downloading file in background on iOS
- FileSystem.ls of an empty directory "returns" an error instead of [] HOT 3
- After updating to 3.0.7 on iOS I get: Multiple commands produce '.../PrivacyInfo.xcprivacy' HOT 2
- writeFile doesn't work properly with ciphered data HOT 3
- Unable to run macos Example / unable manually link for macos
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-file-access.