amplify-swift
amplify-swift copied to clipboard
Question: AWS Amplify Graphql S3 Integration
Reading through the documentation I see this line:
"The GraphQL Transform handles creating the relevant input types and will store pointers to S3 objects in Amazon DynamoDB. The AppSync SDKs and Amplify library handle uploading the files to S3 transparently."
From what I understand, this means by running a graphql request with the described S3Object definition I should be able to do a mutation and by running that mutation upload the data to S3. However, that doesn't happen. I'm curious to know if this functionality exists and how to do it or if I am misinterpreting what's being said, thanks!
https://docs.amplify.aws/cli/graphql-transformer/storage#basics
Hi @obrian33 Can you please provide the code snippet that you are trying. It would be great if you can provide the following details to help us debug the issue:
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Environment(please complete the following information):
- Amplify Framework Version: [e.g. 0.10.0]
- Dependency Manager: [e.g. Cocoapods, Carthage]
- Swift Version : [e.g. 5.0]
Device Information (please complete the following information):
- Device: [e.g. iPhone6, Simulator]
- iOS Version: [e.g. iOS 11]
- Specific to simulators:
Additional context Add any other context about the problem here.
In case of iOS uploading data to S3 is supported for iOS Appsync SDK, please find the documentation here under Working with complex objects
.
But iOS Amplify API category doesnot support complex objects currently.
Thanks for the response!
Here is the additional info requested:
To Reproduce:
Create a Amazon S3 bucket to hold files via amplify add storage.
Create a user pool in Amazon Cognito User Pools via amplify add auth.
Create a GraphQL API via amplify add api and add the following type definition:
type S3Object { bucket: String! region: String! key: String! }
type Picture @model @auth(rules: [{allow: owner}]) { id: ID! name: String owner: String file: S3Object }
Run this mutation with S3 objects from your client app:
mutation ($input: CreatePictureInput!) { createPicture(input: $input) { id name visibility owner createdAt file { region bucket key } } }
Expected Behavior: Uploaded complex S3Object will appear in the specified bucket and region with inputted key.
Environment:
-
Amplify Framework Version: 1.1.1
-
Dependency Manager: Cocoapods
-
Swift Version : 5.0
Device Information:
- Device: iPhone 11 Pro Simulator (13.3)
@royjit Your latest comment seems to address my main concern because I am not using the AWS Mobile SDK but strictly the iOS Amplify API. My current workaround is to run a graphql mutation and then use the Amplify.Storage.uploadData function to upload and then the Amplify.Storage.downloadData function during queries to retrieve the complex objects from S3, is there any plans to include complex object support for Amplify.API?
Yes, you are right that would be the current approach. We will take this as a feature request and will update here when we have more info.
Thanks! Excited to see what comes next :)
related issue on the SDK / AppSync SDK https://github.com/aws-amplify/aws-sdk-ios/issues/1740
@royjit Any updates on using complex objects with Amplify?
We currently do not support performing both the S3 upload and mutation request through one API call, aka "complex objects" support in the SDK. Please see "working with files" documentation for more details. Draft in https://github.com/aws-amplify/docs/pull/5649
Please track https://github.com/aws-amplify/amplify-swift/issues/537 for Complex Object support