Service Application: AWS Part 3

Simon Leen
3 min readOct 28, 2021

--

Objective: Creating A Search Callback System in Unity

In the previous post,we finished up with the ability to save case files to AWS S3. Now we need to be able to to search for a case using the SearchPanel (shown above), download the file and render it back to the user.

To get started we will try and get a list of all the case files stored in the bucket(I say list but it’s really just going to log each case to the console).

We set up the method and call it when the pressing the FIND CASE # button on the main menu(all shown below). This will be moved into the search panel but for now, it’s an empty call without a case number so this is just to get it working.

We found two cases, shown above after pressing the button (cases are saved using random numbers and not sequenced).

Now that we have a reply with case files, time to test the search function. First we get the GetCaseList to take a string input for the case number. Next we create a string for the target case and take that input. Then we simple check each case key from the response to see if one matches and log the case with case number was found. We have moved from the main menu find case button and now use the Search Panel search button and pass the input field value for the case number using the SearchPanel script and ProcessInfo method.

Now that we can get the list and check for the case, some small refactoring to keep things clean. We import the namespace System.Linq to use Linq to prevent logging all objects and just check for the target case.

Next we check if the case has been found and if so use the S3Client to make a call using the bucket name and target case name to run into a series of steps. We check that the response stream is not null then create a byte array for the data. Following this we create and use a StreamReader to read the response. We then use a MemorySteam which gets written to the byte array. We then use another MemorySteam that takes the data(byte array) and using a BinaryFormatter deserialize the fetched case data which gets converted into the active case.

Finally calling the onComplete callback which triggers moving to the SelectPanel from the ProcessInfo method on the SearchPanel.

--

--