src/main/scala/s3/website/model/push.scala in s3_website-2.0.1 vs src/main/scala/s3/website/model/push.scala in s3_website-2.1.0

- old
+ new

@@ -5,11 +5,11 @@ import org.apache.commons.codec.digest.DigestUtils import java.util.zip.GZIPOutputStream import org.apache.tika.Tika import s3.website.Ruby._ import s3.website._ -import s3.website.model.LocalFile.tika +import s3.website.model.Upload.tika import s3.website.model.Encoding.encodingOnS3 import java.io.File.createTempFile import org.apache.commons.io.IOUtils.copy import scala.util.Try @@ -48,21 +48,21 @@ case object RedirectFile extends UploadType { val pushAction = Redirected } -case class LocalFile(originalFile: File, uploadType: UploadType)(implicit site: Site) { +case class Upload(originalFile: File, uploadType: UploadType, reasonForUpload: String)(implicit site: Site) { lazy val s3Key = site.resolveS3Key(originalFile) lazy val encodingOnS3 = Encoding.encodingOnS3(s3Key) /** * This is the file we should upload, because it contains the potentially gzipped contents of the original file. * * May throw an exception, so remember to call this in a Try or Future monad */ - lazy val uploadFile: Try[File] = LocalFile uploadFile originalFile + lazy val uploadFile: Try[File] = Upload uploadFile originalFile lazy val contentType: Try[String] = tika map { tika => val mimeType = tika.detect(originalFile) if (mimeType.startsWith("text/") || mimeType == "application/json") mimeType + "; charset=utf-8" @@ -90,13 +90,13 @@ } /** * May throw an exception, so remember to call this in a Try or Future monad */ - lazy val md5 = LocalFile md5 originalFile + lazy val md5 = Upload md5 originalFile } -object LocalFile { +object Upload { lazy val tika = Try(new Tika()) def md5(originalFile: File)(implicit site: Site): Try[MD5] = uploadFile(originalFile) map { file => using(fis { file }) { DigestUtils.md5Hex }