Journal 132 — Unity App Development, Amazon S3 Find File and Download

Chris Nielsen
3 min readDec 11, 2021

--

Objective: To be able to search and download from data files on Amazon S3

In the previous article, I was able to save a data file and upload to Amazon S3. In this article, I want to go over how to add a search feature to the app and search for a previously uploaded file. I will be referencing the Amazon S3 user guide.

In the app, we have a search panel that we can enter a file/case number.

In the Search script, we will update the ProcessInfo function to call a search function in the AmazonAWS script.

Over in the AmazonAWS script, we can first update the case number entered to match the filename format and get a list of objects.

Next, we need to do a search of those files and if there’s a match, print a Debug.Log statement that a match was found, or no match was found. A little later, we will add code to download the file and get the info.

Now, we can see this in action.

Find file and read data

Now that we found a case file, we need to expand our GetList function:

  • Check that the S3 Response has data
  • If it has data, then read the data
  • If it doesn’t, print a message that no file was found.

Read S3 Data

To read the user data on S3, we need to go through the following steps:

  • create a byte array to hold the data
  • use the StreamReader process to read the data
  • access a MemoryStream to store the data
  • restore the data from the MemoryStream using XML deserialize

Here is how I laid this out. As a test, I put a Debug.Log statement to pull the name that was entered in a case file.

Now let’s see this in action. I just created a new case with number 33, and the name “John Smith”.

And now on the search panel, we can check.

Thank you for your time!

--

--

Chris Nielsen
Chris Nielsen

Written by Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

No responses yet