您将如何以更 kotlinic 的方式编写以下代码?
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
我可以使用let,但我觉得它使代码更难理解