Skip to content

Commit

Permalink
Merge pull request #29 from marcinx27/master
Browse files Browse the repository at this point in the history
getObject and putObject in S3
  • Loading branch information
dwhjames committed Mar 29, 2015
2 parents cc05c10 + 4e87e90 commit 47ccd30
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/main/scala/s3/s3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package com.github.dwhjames.awswrap
package s3

import java.io.{InputStream, File}

import scala.collection.JavaConverters._
import scala.concurrent.{ExecutionContext, Future, Promise}
import scala.util.Try
Expand Down Expand Up @@ -343,6 +345,23 @@ class AmazonS3ScalaClient(
): Future[String] =
getBucketLocation(new GetBucketLocationRequest(bucketName))

/**
* @see [[http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3.html#getObject(com.amazonaws.services.s3.model.GetObjectRequest) AWS Java SDK]]
*/
def getObject(
getObjectRequest: GetObjectRequest
): Future[S3Object] =
wrapMethod[GetObjectRequest, S3Object](client.getObject, getObjectRequest)

/**
* @see [[http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3.html#getObject(com.amazonaws.services.s3.model.GetObjectRequest) AWS Java SDK]]
*/
def getObject(
bucketName: String,
key: String
): Future[S3Object] =
getObject(new GetObjectRequest(bucketName, key))

/**
* @see [[http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3.html#getObjectMetadata(com.amazonaws.services.s3.model.GetObjectMetadataRequest) AWS Java SDK]]
*/
Expand Down Expand Up @@ -440,6 +459,34 @@ class AmazonS3ScalaClient(
): Future[VersionListing] =
listVersions(new ListVersionsRequest(bucketName, prefix, keyMarker, versionIdMarker, delimiter, maxKeys))

/**
* @see [[http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3.html#putObject(com.amazonaws.services.s3.model.PutObjectRequest) AWS Java SDK]]
*/
def putObject(
putObjectRequest: PutObjectRequest
): Future[PutObjectResult] =
wrapMethod[PutObjectRequest, PutObjectResult](client.putObject, putObjectRequest)

/**
* @see [[http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3.html#putObject(com.amazonaws.services.s3.model.PutObjectRequest) AWS Java SDK]]
*/
def putObject(
bucketName: String,
key: String,
file: File
): Future[PutObjectResult] =
putObject(new PutObjectRequest(bucketName, key, file))

/**
* @see [[http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3.html#putObject(com.amazonaws.services.s3.model.PutObjectRequest) AWS Java SDK]]
*/
def putObject(
bucketName: String,
key: String,
input: InputStream,
metadata: ObjectMetadata
): Future[PutObjectResult] =
putObject(new PutObjectRequest(bucketName, key, input, metadata))
}

/**
Expand Down

0 comments on commit 47ccd30

Please sign in to comment.