def upload()

in app/lib/S3Actions.scala [50:72]


  def upload(file: File, user: User, config: Config, setPublicAcl: Boolean): S3UploadResponse = {

    getObject(config.key(file.getName), config.bucketName, config.s3Client) match {
      case None => {
        val metadata = new ObjectMetadata
        metadata.addUserMetadata("author", user.email)
        if(setPublicAcl) { metadata.setContentType("text/html") }

        val request = new PutObjectRequest(config.bucketName, config.key(file.getName), file).withMetadata(metadata)

        val finalRequest = if(setPublicAcl) {
          request.withCannedAcl(CannedAccessControlList.PublicRead)
        } else { request }

        config.s3Client.putObject(finalRequest) match {
          case _: PutObjectResult => S3UploadResponse.buildSuccess(finalRequest, config)
          case _ => S3UploadFailure(None, Some(file.getName), Some("Upload Failed"))
        }

      }
      case _ => S3UploadFailure(None, Some(file.getName), Some("File with that name already exists"))
    }
  }