Unity Development for Enterprise Applications
Storage with Amazon S3 using AWS in Unity (Part 2)
//Searching the S3 storage for a file and loading it.
Alright, so we learned how to save a file to the hardware and to the S3 storage on the AWS cloud but that isn’t enough. We also need to be able to retrieve the file from the cloud for future usage.
So lets dive right in!
Searching for the file
Searching for the file will use the Amazon HTTPS web request and response tools. This might seem like a bunch of code but what we are doing is a lot of checking variable setup, and null checking.
The code uses several lambda expressions to make it easier to read. We setup a request and stuff the results into a responseObject. We then make sure that object is not null and if it isn’t using a lambda expression combined with LINQ to see of the caseID we are looking for can be found anywhere in the bucket. If it can the LoadCase() method is called to takeover. There is a bug in this code, can you spot it? I will reveal it a little later.
public void SearchCase(int caseID)
{
var request = new ListObjectsRequest() { BucketName = "testcasefilesunity" };