diff options
author | vlad <vlad@driver.xyz> | 2017-06-29 20:19:30 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-06-29 20:19:30 -0700 |
commit | 5013a7fde52e4459c12ff5e92793cad9fc2f23db (patch) | |
tree | 00be653526aac5b20ec528204b5dda4153becbfb /src/main/scala/xyz/driver/core/file/S3Storage.scala | |
parent | 0e6a5d1dbaf02192cc5ad5ff6edbb793dc6a1287 (diff) | |
parent | e41050b75308aab2736eea11b67bf9387a90dfe5 (diff) | |
download | driver-core-5013a7fde52e4459c12ff5e92793cad9fc2f23db.tar.gz driver-core-5013a7fde52e4459c12ff5e92793cad9fc2f23db.tar.bz2 driver-core-5013a7fde52e4459c12ff5e92793cad9fc2f23db.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/main/scala/xyz/driver/core/file/S3Storage.scala')
-rw-r--r-- | src/main/scala/xyz/driver/core/file/S3Storage.scala | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/scala/xyz/driver/core/file/S3Storage.scala b/src/main/scala/xyz/driver/core/file/S3Storage.scala index 933b01a..7df3db2 100644 --- a/src/main/scala/xyz/driver/core/file/S3Storage.scala +++ b/src/main/scala/xyz/driver/core/file/S3Storage.scala @@ -15,13 +15,13 @@ import scalaz.{ListT, OptionT} class S3Storage(s3: AmazonS3, bucket: Name[Bucket], executionContext: ExecutionContext) extends FileStorage { implicit private val execution = executionContext - def upload(localSource: File, destination: Path): Future[Unit] = Future { + override def upload(localSource: File, destination: Path): Future[Unit] = Future { checkSafeFileName(destination) { val _ = s3.putObject(bucket.value, destination.toString, localSource).getETag } } - def download(filePath: Path): OptionT[Future, File] = + override def download(filePath: Path): OptionT[Future, File] = OptionT.optionT(Future { val tempDir = System.getProperty("java.io.tmpdir") val randomFolderName = randomUUID().toString @@ -36,11 +36,11 @@ class S3Storage(s3: AmazonS3, bucket: Name[Bucket], executionContext: ExecutionC } }) - def delete(filePath: Path): Future[Unit] = Future { + override def delete(filePath: Path): Future[Unit] = Future { s3.deleteObject(bucket.value, filePath.toString) } - def list(path: Path): ListT[Future, FileLink] = + override def list(path: Path): ListT[Future, FileLink] = ListT.listT(Future { import scala.collection.JavaConverters._ val req = new ListObjectsV2Request().withBucketName(bucket.value).withPrefix(path.toString).withMaxKeys(2) @@ -63,4 +63,9 @@ class S3Storage(s3: AmazonS3, bucket: Name[Bucket], executionContext: ExecutionC } filterNot isInSubFolder(path) } toList }) + + override def exists(path: Path): Future[Boolean] = Future { + s3.doesObjectExist(bucket.value, path.toString) + } + } |