Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const RNFS = require('react-native-fs');
- const dirHome = Platform.select({
- ios: `${RNFS.DocumentDirectoryPath}/Pictures/OutletClassification`,
- android: `${RNFS.ExternalStorageDirectoryPath}/Pictures/OutletClassification`
- });
- const dirPicutures = `${dirHome}/Pictures`;
- const downloadFile = async (url, newFilepath) => {
- console.log('process moved')
- return new Promise((resolve, reject) => {
- RNFS.mkdir(dirPicutures)
- .then(() => {
- RNFS.downloadFile({fromUrl:url, toFile: newFilepath}).promise.then(res => {
- console.log('Download result', res)
- this.setState({ downloaded: true });
- });
- })
- .catch(err => {
- console.log('mkdir error', err);
- reject(err);
- });
- });
- };
- ==========
- itemPhoto.reduce(async (result,val) =>{
- console.log('loop photo', val)
- const url = this.state.url+val.picture;
- const newImageName = `${Moment().format('DDMMYY_HHmmssSSS')}.jpg`;
- const newFilepath = `${dirPicutures}/${newImageName}`;
- arrItemPhoto.push({
- id: xItem + 1,
- picture: newFilepath,
- })
- xItem++;
- const download = await downloadFile(url, newFilepath);
- },{})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement