From the course: Learning AWS Amplify (2020)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

File storage from the app

File storage from the app - Amazon Web Services (AWS) Tutorial

From the course: Learning AWS Amplify (2020)

Start my 1-month free trial

File storage from the app

- [Instructor] So now we want to store our files online. On line 215, we call storeOnline for the item and in the completion block, we want to store the file. So let's write a new function after storeOnline. We're going to need some classes from the S3 SDK so let's import that at the top. So back up at the top, under the import statements, we have currently I'll import AWSS3. I'm going to search for storeOnline and write a new function just above that. So on line 223, I'll start with func upload and it's going to take a parameter called img, that's a UIImage, and also, a parameter name that's a String. This'll be the name of the file. And a completion handler. I'll mark that as escaping again, so we can call it within another block and this closure takes a Bool and returns Void. Now, the first thing we want to do is make sure that we can convert this image to data so I'll say guard let data equal img.png data, else…

Contents