Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of how to control AWS from R
awsAccessKeyText <- "yourKeyHere"
awsSecretKeyText <- "yourSecretKeyHere"
pathToSdk <- "/home/jal/aws-java-sdk-1.1.0/"
testFile <- "/home/jal/aws-java-sdk-1.1.0/rJavaExamples/testFile.tst"
.jaddClassPath(paste(pathToSdk, "lib/aws-java-sdk-1.1.0.jar", sep=""))
.jaddClassPath(paste(pathToSdk, "third-party/commons-logging-1.1.1/commons-logging-1.1.1.jar", sep=""))
.jaddClassPath(paste(pathToSdk, "third-party/commons-httpclient-3.0.1/commons-httpclient-3.0.1.jar", sep=""))
.jaddClassPath(paste(pathToSdk, "third-party/commons-codec-1.3/commons-codec-1.3.jar", sep=""))
attach( javaImport( "java.lang" ) )
attach( javaImport( "" ) )
awsCreds <- new(com.amazonaws.auth.BasicAWSCredentials, awsAccessKeyText, awsSecretKeyText)
tx <- new(, awsCreds)
bucketName <- paste("s3-upload-sdk-sample-", tolower(awsAccessKeyText), sep="")
s3 <- tx$getAmazonS3Client()
#test if the bucket exists; if not, make bucket
if (s3$doesBucketExist(bucketName) == FALSE) {
fileToUpload <- new(File, new(String, testFile))
request <- new(, bucketName, fileToUpload$getName(), fileToUpload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.