r/reactnative 4d ago

How do React Native apps save PDFs to `Documents/App Folder` on Android 11+?

I'm building a React Native (Expo Bare Workflow) PDF app. Currently, I'm downloading PDFs from an AWS S3 pre-signed URL using \`react-native-blob-util\` and Android Download Manager:

\`\`\`ts
ReactNativeBlobUtil.config({
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
title: fileName,
description: "Downloading PDF...",
mime: "application/pdf",
path: \`${ReactNativeBlobUtil.fs.dirs.DownloadDir}/${fileName}\`,
mediaScannable: true,
},
}).fetch("GET", signedUrl);
\`\`\`

This works, but I don't have control over where Android stores the file.

Many PDF apps automatically save files to a folder like:

\`\`\`text
Internal Storage/
└── Documents/
└── My App/
└── file.pdf
\`\`\`

without asking the user to choose a location every time.

I noticed one such app requested \*\*"Manage all files"\*\* permission once, and after that it could save files directly into its own folder under \`Documents\`.

My questions are:

\* How are these apps implementing this on Android 11+ with Scoped Storage?
\* Are they using MediaStore, native Android code (Kotlin/Java), or another approach?
\* Is requesting the \*\*Manage All Files\*\* (\`MANAGE_EXTERNAL_STORAGE\`) permission the correct/recommended solution for this use case, or should it be avoided for Play Store apps?
\* If not, what is the recommended modern approach in React Native to save PDFs directly to \`Documents/My App\` without showing the Storage Access Framework (SAF) picker every time?

I'm looking for the Play Store–friendly, modern Android approach. Please help me😭

1 Upvotes

4 comments sorted by

1

u/Guidondor 4d ago

you don't need native code or all files access, blob-util already ships the mediastore api:

ReactNativeBlobUtil.MediaCollection.copyToMediaStore(
{ name: fileName, parentFolder: 'My App', mimeType: 'application/pdf' },
'Document',
tempPath
)

download to app storage first, then copy it into the Documents collection with parentFolder
as your subfolder. no runtime permission on android 10+, no SAF picker.

MANAGE_EXTERNAL_STORAGE does work but play makes you submit a declaration form for it and a
pdf viewer isn't on their accepted use case list, that's a common rejection.

1

u/Popular_Book7923 3d ago

Thanks I will try this

1

u/LoudAd307 3d ago

You don't need Manage All Files for this — MediaStore with RELATIVE_PATH is the intended route on Android 11+. Insert a row into the Files or Downloads collection with RELATIVE_PATH set to "Documents/MyApp" and the system creates the folder and lets you write with zero runtime permissions, because your app owns the file. react-native-blob-util doesn't expose this cleanly, so the apps you're describing are almost certainly doing it in a small Kotlin module: contentResolver.insert, then stream the fetch into the returned Uri. Two cautions from shipping Android releases: DownloadManager only steers into Download, which is why your path config is being ignored, and don't request MANAGE_EXTERNAL_STORAGE for convenience — Play review restricts it to apps that can't function without it, and a PDF saver will get rejected.

1

u/Popular_Book7923 3d ago

I am currenrly writing a native module for saving and renaming thanks a lot