How would you write the following code in a more kotlinic way ?
var returnValue = ...
val s3data = presignedUrl.body()
if (s3data != null) {
val uploadImage = api.uploadImage(s3data.bucketUrl, s3data.awsAccessKeyId, s3data.policy, s3data.key, s3data.signature, body).execute()
if (!uploadImage.isSuccessful) {
crashReporterService.sendIssue("Failed uploading file", "Failed uploading file ${uploadImage.raw()}")
returnValue = Result.FAILURE
} else {
returnValue = Result.SUCCESS
}
} else {
crashReporterService.sendIssue("Failed uploading image", "Error - ${presignedUrl.raw()}")
returnValue = Result.FAILURE
}
return returnValue
I can use let, but I feel it makes the code more complicated to understand