def getJsonString()

in src/main/scala/com/gu/liveappversions/S3Storage.scala [59:75]


  def getJsonString(env: Env, bucketName: String, partialKey: String): Try[Option[String]] = {
    val key = fullKey(env, partialKey)
    Try {
      val s3Object = s3Client.getObject(bucketName, key)
      Source.fromInputStream(s3Object.getObjectContent).mkString
    } match {
      case Success(result) =>
        logger.info(s"Successfully downloaded file from S3 (bucket: $bucketName | key: $key)")
        Success(Some(result))
      case Failure(amazonServiceException: AmazonServiceException) if (amazonServiceException.getStatusCode == 404) =>
        logger.info(s"File was not present in s3 (bucket: $bucketName | key: $key)")
        Success(None)
      case Failure(exception) =>
        logger.error(s"Failed to download file from S3 (bucket: $bucketName | key: $key) due to: $exception")
        Failure(exception)
    }
  }