uploadToDiawi method
Main upload method that handles both APK and IPA files
Implementation
Future<String?> uploadToDiawi(String filePath) async {
try {
// Validate file exists
final file = File(filePath);
if (!file.existsSync()) {
print('β File not found: $filePath');
return null;
}
// Detect file type
final fileExtension = path.extension(filePath).toLowerCase();
if (fileExtension != '.apk' && fileExtension != '.ipa') {
print(
'β Unsupported file type. Only .apk and .ipa files are supported.');
return null;
}
print(
'π€ Uploading ${fileExtension.substring(1).toUpperCase()} to Diawi...');
// Step 1: Upload file and get job token
final jobToken = await _uploadFile(file);
if (jobToken == null) {
print('β Failed to upload file to Diawi');
return null;
}
print('β
File uploaded successfully. Job token: $jobToken');
print('β³ Processing upload... This may take a few minutes.');
// Step 2: Poll for status
final downloadLink = await _pollForStatus(jobToken);
if (downloadLink != null) {
print('β
Upload completed successfully!');
FlutterReleaseXIndividualUploadService.updateUrlLinkState(downloadLink);
return downloadLink;
} else {
print('β Failed to get download link from Diawi');
return null;
}
} catch (e) {
print('β Error uploading to Diawi: $e');
return null;
}
}