Expo File System pauseAsync gives error 'No download object available'

  1. SDK Version: 35.0.0
  2. Platforms(Android/iOS/web/all): Android

I am using the expo-file-system to create a resumable download. I am using the same example as in the expo documentation.

The download part is working good. It downloads the file and gives progress along the way. But when I try to us the pauseAsync function it gives the error.

‘No download object available’

export default function App() {
const [downloadProgress,setDownloadProgress] = useState({})

const callback = downloadProgress => {
const progress = downloadProgress.totalBytesWritten / downloadProgress.totalBytesExpectedToWrite;
console.log(progress);
setDownloadProgress(progress)
};

const downloadResumable = FileSystem.createDownloadResumable(
'http://techslides.com/demos/sample-videos/small.mp4',
FileSystem.documentDirectory + 'small.mp4',
{},
callback
);

startDownload = async() =>{

try {
  const { uri } = await downloadResumable.downloadAsync();
  console.log('Finished downloading to ', uri);
} catch (e) {
  console.error(e);
}
}

pauseDownload = async() =>{
try {
  await downloadResumable.pauseAsync();
  console.log('Paused download operation, saving for future retrieval');
  AsyncStorage.setItem('pausedDownload', JSON.stringify(downloadResumable.savable()));
} catch (e) {
  console.error(e);
}
}


return (
<View style={{    flex: 1,backgroundColor: '#fff',alignItems: 'center',justifyContent: 'center',marginTop: 20}}>
  <TouchableNativeFeedback onPress = {this.startDownload}>
    <View style={{alignItems:'center',justifyContent:'center',height:50,width:100,backgroundColor:'#00f',marginBottom:2}}>
      <Text style={{color:'#fff'}}>Download</Text>
    </View>
  </TouchableNativeFeedback>

  <TouchableNativeFeedback onPress = {this.pauseDownload}>
    <View style={{alignItems:'center',justifyContent:'center',height:50,width:100,backgroundColor:'#00f',marginBottom:2}}>
      <Text style={{color:'#fff'}}>Pause</Text>
    </View>
  </TouchableNativeFeedback>
</View>
);
}

Hey @rafaysaleem,

Could you package this up into a Snack that reproduces the issue so that we can reliably test it on our end?

Cheers,
Adam

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.