com.gu.permissions.PermissionsS3.scala Maven / Gradle / Ivy
package com.gu.permissions
import java.io.InputStream
import java.util.Date
import com.amazonaws.services.s3.AmazonS3
trait PermissionsS3 {
def getObject(bucket: String, key: String): (InputStream, Date)
}
object PermissionsS3 {
// IntelliJ says we can roll this up into a Single Abstract Method but we can't because if we do compiling fails on
// Scala 2.11 sigh...
def apply(s3Client: AmazonS3): PermissionsS3 = new PermissionsS3 {
override def getObject(bucket: String, key: String): (InputStream, Date) = {
val result = s3Client.getObject(bucket, key)
(result.getObjectContent, result.getObjectMetadata.getLastModified)
}
}
}