From the course: AWS for Developers: S3

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Binary object manipulation

Binary object manipulation

- [Instructor] So now it's time to work with some individual files using the Java SDK for S3. I think that you'll see that once again, we follow the same pattern over and over that we did with the createBucket. So let's start off here by creating some methods, so public void. First thing we want to do is upload a file, so we need to send in a bucket, a localFile, a localDirectory, and a key, and we'll do a try once again, but this time we're going to use the PutObjectRequest, which once again, has a builder. To that builder, we will add our bucket, we will add our key, now we'll call it s3.putObject, we will pass in our request. Okay, now we're going to use the paths from java.nio.file, and we're going to use the get, and we're going to pass it the local directory, and then the local file, and it will assemble that directory for us. Now we once again catch Exception, and much like I did before, I'm going to copy…

Contents