download method
Implementation
@override
Future<ParseXFile> download({ProgressCallback? progressCallback}) async {
if (url == null) {
return this;
}
progressCallback ??= _progressCallback;
_cancelToken = CancelToken();
if (parseIsWeb) {
final ParseNetworkByteResponse response = await _client.getBytes(
url!,
onReceiveProgress: progressCallback,
cancelToken: _cancelToken,
);
if (response.bytes != null) {
file = XFile.fromData(response.bytes as Uint8List);
}
} else {
file = XFile('${ParseCoreData().fileDirectory}/$name');
await File(file!.path).create();
final ParseNetworkByteResponse response = await _client.getBytes(
url!,
onReceiveProgress: progressCallback,
cancelToken: _cancelToken,
);
await File(file!.path).writeAsBytes(response.bytes!);
}
return this;
}