Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getObject and putObject in S3 #29

Merged
merged 1 commit into from
Mar 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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