Comments (2)
Can you please show the difference in code before and after your fix for Android 9?
from react-native-blob-util.
@RonRadtke on android 9 i am calling for run time permissions before writing the stream, rest is same below is the code
requestReadWritePermission(){
console.log("Request Read Write Permission for Android");
return PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE
);
}
this.requestReadWritePermission()
.then(res => {
console.log(res)
if (res == PermissionsAndroid.RESULTS.GRANTED) {
console.log('read write permission granted' + JSON.stringify(res))
let {dirs} = ReactNativeBlobUtil.fs;
const dirToSave = dirs.DownloadDir;
let PATH_TO_FILE = dirs.DownloadDir + '/' + json.fileName.replace(/ /g, '') + '.pdf';
ReactNativeBlobUtil.fs.writeStream(
PATH_TO_FILE,
// encoding, should be one of `base64`, `utf8`, `ascii`
'base64',
// should data append to existing content ?
true
)
.then(stream => Promise.all([
stream.write(json.fileContent)
]))
// Use array destructuring to get the stream object from the first item of the array we get from Promise.all()
.then(([stream]) => {
stream.close()
ToastAndroid.show('File saved in downloads', ToastAndroid.LONG)
})
.catch(console.error)
} else {
console.log('read write permission not' + JSON.stringify(res))
}
})
.catch(console.error)
from react-native-blob-util.
Related Issues (20)
- After reinstalling the application, the images recorded by the library are no longer available HOT 5
- Could not determine the dependencies of task ':react-native-blob-util:compileDebugAidl'. (React Native) HOT 1
- android6正常下载,android6以上没有任何反应 HOT 1
- Android 14: Error: Download manager download failed, the file does not downloaded to destination. HOT 12
- react native windows can't able use react-native-blob-util i get error
- iOS fetch uploads empty file HOT 1
- [RangeError: Property storage exceeds 196607 properties] when fetch PUT a 84KB jpg file HOT 1
- Errors in react-native-web HOT 4
- Is it possible to create a blob from a local image uri? HOT 5
- there is warn when ios building
- How to async/await in `readStream`
- react-native-blob-util--fs.isDir Invocation Error
- iOS privacy manifest HOT 1
- Android Download Manager notification only shows up at the end
- response.json() is throwing an Error in Android saying No such file or directory HOT 1
- dest.exists() check fails in writeStream() in files of type content:// HOT 1
- Using writeStream() with content:// Uris HOT 1
- File gets corrupted with readStream() with base64 when using bufferSize defaults
- java to kotlin change example HOT 5
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-blob-util.