Uploading to S3

Jordan Evans
3 min readDec 18, 2021

--

Now that we have buckets all set up, let’s take a look at how we can upload our case information. What we can use as a small guide for what we need to do is some Dev guides that AWS has provided to us here.
To start, we will want to change our AWSManager into a singleton:

Once we have this all set up, we are going to adjust our S3Client so that we can always have access to it. To do this, let’s change it up to make it a variable:

With these 2 things set up, let’s go ahead and create the void for us to Upload to S3:

What all of does is create the parameters of our upload request and fills out the constructor of that request. As with the PostObject portion, this is set up so that we have logs being printed whether or not the upload was successful or not. With that all set up, we need to attach this to our submit button on the UIManager so that we call upon this method:

Let’s now take a look at what it all looks like when we have uploaded it to our bucket:

As we can see, we have a case file uploaded to the bucket, however we also need to open all of the folders that the file is located within.
To fix this issue, we will make a couple small tweaks to the code:

What we have done is instead of having our key be the file name, which is the complete path to the file, we have made it just the caseID information. This will cut out all the spare folders and place just the file within our bucket. As well, we are going to create a reset functionality as well to the submit button so that when the user clicks save and the information successfully uploads, it will bring the user back to the main menu:

Now that we have successfully uploaded our information to AWS, we will begin to look at the process in which we need to have our information pulled back into the app from the S3 bucket.

--

--

No responses yet