Amazon S3 module for Play Framework 2
resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.thibaultmeyer" % "play-s3-module" % "release~YY.MM"
## Amazon AWS
# ~~~~~
aws {
authKey = "your-access-key"
authSecret = "your-secret-key"
# Amazon S3 Plugin
# ~~~~~
# https://github.com/thibaultmeyer/play-s3-module
s3 {
endPoint = "s3-eu-west-1.amazonaws.com"
signingRegion = "eu-west-1"
withPathStyle = false
disableChunkedEncoding = false
bucketName = "your-bucket"
publicUrl = "https://s3-eu-west-1.amazonaws.com/"
}
}
## Ebean
# https://github.com/payintech/play-ebean
# ~~~~~
ebean {
servers {
default {
enhancement = ["models.*", "com.zero_x_baadf00d.play.module.aws.s3.ebean.S3FileModel"]
}
}
}
public class MyController extends Controller {
public Result index() {
// Do something with PlayS3.getAmazonS3()
return ok();
}
}
public class MyController extends Controller {
public Result index() {
final File avatar = new File("/tmp/avatar.png");
final S3FileModel s3avatar = new S3FileModel();
s3avatar.setName("avatar.png");
s3avatar.setSubDirectory("account-avatar");
s3avatar.setObject(avatar);
s3avatar.setContentType("image/png");
s3avatar.save();
return ok(s3avatar.getUrlAsString());
}
}
This project is released under terms of the MIT license.