Skip to content

Commit

Permalink
chore: merge main into next-release/main (#7203)
Browse files Browse the repository at this point in the history
* Minor edits to Vite + React quickstart (#6926)

* Updates to Vite + React quickstart

* Update src/fragments/gen2/quickstart/build-a-backend.mdx

Co-authored-by: Kevin Old <kevold@amazon.com>

* Update build-a-backend.mdx

* Update build-a-backend.mdx

* Update build-a-backend.mdx

---------

Co-authored-by: Kevin Old <kevold@amazon.com>

* fix: Fix incorrect auth import path in migration guide. (#6934)

* fix: Update incorrect `updateMFAPreference` parameter in JS v6 migration guide. (#6935)

* Amplify Android Release 2.14.11 (#6933)

* chore: refactor .layout-header into separate component (#6826)

* platform typed as optional

* refactor init

* remove commented code

* remove angry useEffect

* fix typing

* added layoutcontext so mobile menu closes on navigation

* move import

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* fix: Nesting of auth cli templates (#6932)

* fix: change config variable name (#6923)

* Guide to support Amplify v2 with AWS Android SDK (#6927)

* Update puppeteer (#6949)

* Update index.mdx (#6950)

* Update CODEOWNERS with correct PM alignment (#6951)

* fix(flutter, js): scope "connect existing cdk" guide to respective platform (#6947)

Co-authored-by: Tim Nguyen <54393192+timngyn@users.noreply.github.com>

* Revert "fix(flutter, js): scope "connect existing cdk" guide to respective pl…" (#6955)

This reverts commit 5998b22.

* chore: remove duplicated logic between Layout and LayoutHeader (#6954)

* chore: more layout refactoring

* remove unused prop, alphabetize props

* improve oauth docs (#6961)

* fixed gen 2 getting started guide (#6968)

* Update redirects for deleted hidden pages (#6944)

* Update manual installation to point to @beta tag (#6972)

* include usage for multi-page apps (#6964)

* include usage for multi-page apps

* improve multi-page app docs

* use Hub syntax

* update imports in examples

* chore: Clean up broken Amplify JS API reference links (#6976)

* chore: Clean up broken Amplify JS API reference links.

* Cleaned up language.

* Update build image instructions for Gen 2 (#6978)

* update build image settings for Gen 2

* remove callout and add fragment to vite guide

* chore: add unit test for YoutubeEmbed component (#6983)

* chore: add unit test for YoutubeEmbed component

* add code coverage stats

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for Accordion component (#6981)

* chore: add unit tests for Accordion component

* issue with window properties

* fixed tracking test

* working on animation issue

* accordion tests

* fix testing errors

* added test for closing accordion

* add code coverage stats

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* Update index.mdx (#6986)

* Add env variables for algolia (#6957)

* Add algolia env vars to next.config

* Remove extra code string

* fix(data): update REST API docs to document correct error response type (#6989)

* fix(data): update React Native minimum iOS deployment target guidance; add build step to docs (#6970)

* fix(data): update React Native minimum iOS deployment target; add build step to docs

* address PR feedback

* remove deployment target guidance

* add React Native version deployment target callout

* fix unrecognized syntax

* replace callout with accordion

* move 'upgrading' callout

* Clarify behavior of forgetDevice() API regarding device tracking (#6985)

* Clarify behavior of forgetDevice() API regarding device tracking

This commit updates the documentation to clarify that using the forgetDevice() API results in the device being neither remembered nor tracked. Previously, the documentation suggested that forgotten devices might still be tracked, leading to confusion about the API's behavior. The revised wording aligns with the detailed description under the "Forgotten" section, ensuring consistency and eliminating ambiguity about how forgotten devices are handled.

* Clarify behavior of forgetDevice() API regarding device tracking

* Support for enum value listing (#6885)

* Support for enum value listing

* Update src/pages/gen2/build-a-backend/data/data-modeling/add-fields/index.mdx

* CDK updates v2 (#6990)

* Add padding to bottom of nav menu (#6991)

* Adding secondary index to Gen 2 (#6996)

* Adding secondary index docs

* fixed some formatting for custom query fields

* extend config to show addOuput (#6963)

* extend config

* modify wording

* modify example

* improve wording

* Update index.mdx (#6995)

* Update index.mdx

* add guest access support to docs

* chore: add unit tests for NextPrevious component (#7003)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for LinkCards and LinkCard components (#7006)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for GetStartedPopover component (#7005)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* fix: [Storage] Configure Access (#6948)

Co-authored-by: Tim Nguyen <54393192+timngyn@users.noreply.github.com>

* fix(Swift): update data use policy info's tracking to false (#6938)

* fix(Swift): update data use policy info's tracking to false

* Update data-information.mdx

* chore: add callouts and troubleshooting guide for configuration (#6967)

* fix: resolve in-content broken links (#7011)

* re-platforming

* remove reference to mocking and testing for android & swift

* remove reference to mocking and testing for android & swift

* filtered out reference to optimistic ui for react native

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* update gen2 storage and function docs (#7009)

* update gen2 storage and function docs

* add resource access links and example

* revisions, update code snippet titles

* Update CODEOWNERS (#7014)

* updated steps for extending components in code (#6827)

Co-authored-by: Aditya Shahani <theadi@amazon.com>

* Custom business logic support as of March @beta (#7019)

* Enhanced custom business logic DX

* addressed tim's comments

* Added custom subscription configuration worfklow

* removed in-development areas

* added titles

* added links for deep dive material

* Update src/pages/gen2/build-a-backend/data/custom-business-logic/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* Update src/pages/gen2/build-a-backend/data/custom-business-logic/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* Update src/pages/gen2/build-a-backend/data/custom-business-logic/index.mdx

Co-authored-by: Kethan sai <ykethan@amazon.com>

* Update src/pages/gen2/build-a-backend/data/custom-business-logic/index.mdx

Co-authored-by: Kethan sai <ykethan@amazon.com>

* Update src/pages/gen2/build-a-backend/data/custom-business-logic/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* Update src/pages/gen2/build-a-backend/data/custom-business-logic/index.mdx

* added client method for clarity.

* Update src/pages/gen2/build-a-backend/data/custom-business-logic/index.mdx

Co-authored-by: Kethan sai <ykethan@amazon.com>

* Apply suggestions from code review

Co-authored-by: josef <josef.aidt@gmail.com>

---------

Co-authored-by: josef <josef.aidt@gmail.com>
Co-authored-by: Kethan sai <ykethan@amazon.com>

* add storage trigger docs (#7020)

* storage trigger docs

* Apply suggestions from code review

Co-authored-by: josef <josef.aidt@gmail.com>

* add storage access actions

---------

Co-authored-by: josef <josef.aidt@gmail.com>

* update link checker to wait for each call to complete before making t… (#6993)

* update link checker to wait for each call to complete before making the next and remove # from urls being checked

* update logging to show how many links found on each page

* Update tasks/link-checker.js

---------

Co-authored-by: Jacob Logan <lognjc@amazon.com>
Co-authored-by: katiegoines <katiegoines@gmail.com>
Co-authored-by: Scott Rees <6165315+reesscot@users.noreply.github.com>

* custom examples (#6979)

* custom examples

* fix: broken link, missing / at start (#7026)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* validate and fix code snippets in Data section (#6975)

* Update sandbox --dir-to-watch description (#7031)

* Update index.mdx (#7035)

* Fix link (#7028)

* add docs to auth resource access pattern (#7032)

* fix: type platform as optional in Breadcrumbs component & add unit tests (#6912)

* platform typed as optional

* chore: add unit tests for Breadcrumbs

* testing to include platform optional

* fix: type platform as optional

* add tests for override values

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* fix: proper variable naming conventions for storage (#7033)

fix:  proper variable naming conventions for storage

* remove explicit file extension from gen2 imports (#6946)

Co-authored-by: Tim Nguyen <54393192+timngyn@users.noreply.github.com>

* fix: Update diff code blocks to TypeScript with code highlights (#6905)

* add docs on granting defineFunction access to defineData (#7029)

* standardize Gen 2 wording (#7036)

* Update index.mdx (#6906)

* Modify_Amplify_resources (#7018)

* fix code snippets on read data page

* code snippet updates

* updated the code snippets

* updated code snippets.

* custom business page rollback

* Update maplibre links (#7040)

* chore: add unit tests for PlatformNavigator (#6980)

* chore: add unit tests for PlatformNavigator

* add code coverage

* simplify

* simplify

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* Update links to expo docs (#7044)

* Update links to expo docs

* Update src/pages/[platform]/prev/build-a-backend/auth/add-social-provider/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* Update src/pages/[platform]/prev/build-a-backend/auth/add-social-provider/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

---------

Co-authored-by: josef <josef.aidt@gmail.com>

* chore: add unit tests for InternalLinkButton (#7000)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add addtl unit test for Block component (#6982)

* chore: add addtl unit test for Block component

* add code coverage stats

* remove superfluous Block component

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for TOC (#6984)

* chore: add unit tests for TOC

* add code coverage

* hardcode expected hash

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for ExternalLink (#6915)

* chore: add unit tests for ExternalLink

* fixing tracking test

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for ExternalLinkButton (#6914)

* chore: add unit tests for ExternalLinkButton

* Update ExternalLinkButton.test.tsx

triggering checks

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for Footer component (#6999)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for MigrationAlert component (#7004)

* chore: add unit tests for MigrationAlert component

* chore: add unit tests for MigrationAlert component

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit test for Overview component (#7002)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: upgrade docsearch/react to 3.6 (#7046)

* added utility type content (#7047)

* chore: add unit tests for PageLastUpdated (#7001)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore: add unit tests for Commands and Columns (#6916)

* chore: add unit test for CLICommands

* chore: add unit test for Columns

* Update Command.test.tsx

triggering checks

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* Update resolution for follow-redirects (#7055)

* Update relative urls (#7048)

* Update relative urls

* Update url

* Updating link checker (#7052)

* Updating link checker to account for duplicate urls from different pages and link text

* Update slack formatting

* Remove console.log

* Add comments to function

* Remove extra console.logs()

* chore: update redirects list (#6969)

* update redirects

* updated redirects

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* remove allowlist role names for appsync console access page (#7081)

* Add JavaScript resolver code sample to Gen 1 (#7087)

* fix(JS): Update v5 JS libraries installation guides. (#7090)

* fix(v5): update aws-amplify v5 dependency

* chore: remove extra '0' number from versions

* chore: remove vue2 block

* chore: update version reference

* Cbonif/field-level-auth-support-for-sql (#7091)

* chore(gen2-data): update .secondaryIndexes example to match the latest interface (#7095)

* update setup auth client example with correct props (#7106)

* update auth with correct props

* Change generated function env package name (#7096)

* Update typo in url for localhost (#7110)

* update next config to use a static build Id (#7102)

Co-authored-by: Jacob Logan <lognjc@amazon.com>

* chore: Add callout on Analytics buffer persistence in Amplify JS (#7115)

* chore: Add callout on Analytics buffer persistence in Amplify JS.

* PR feedback.

* Custom subscription docs to Gen 2 (#7120)

* Add playsInline to videos (#7125)

* autoSignIn position correction in v6 migration docs (#7059)

* fix(next-release/main): update home page h1 and code block font size (#7117) (#7126)

* update font sizes

* add text-size-adjust

* add webkit prefix, add comment

* update text-size-adjust fix

---------

Co-authored-by: Tim Nguyen <54393192+timngyn@users.noreply.github.com>

* remove parenthesis from "Amplify (Gen 2)" (#7113)

* change "NPM" to "npm" (#7112)

* remove explicit ".js" extension from gen2 resource imports (#7134)

* remove leading slash from storage access paths (#7116)

* remove unnecessary "Angular" mention in auth getting started (#7139)

Removed 'Angular' from the app description. It is not necessarily an angular app.

* Gen 2 Quickstart: Fix amplify console link (#7141)

* fix amplify console link

* fix text from AWS Console to Amplify Console

* updated alt text for Amplify console

* Update src/fragments/gen2/quickstart/deploy-and-host.mdx

Co-authored-by: Scott Rees <6165315+reesscot@users.noreply.github.com>

* Update src/pages/gen2/deploy-and-host/fullstack-branching/branch-deployments/index.mdx

Co-authored-by: Scott Rees <6165315+reesscot@users.noreply.github.com>

---------

Co-authored-by: Scott Rees <6165315+reesscot@users.noreply.github.com>

* Add Favicon and apple-touch icons to root (#7137)

* add 96x96 favicons

* add favicon and apple-touch to root

* updated icons

---------

Co-authored-by: Jacob Logan <lognjc@amazon.com>

* docs(migration): fixes mislabeling notification enable snippet (#7135)

the v5 snippet was labeled as v6 and the v6 was labeled as v5

Co-authored-by: derrik.fleming <derrik.fleming@spindance.com>

* edits to custom business logic (#7129)

* remove console.log (#7147)

* fix: copied code no longer includes markdown comments (#7146)

* fix: copied code no longer includes markdown comments

* minor cleanup

* splite prepareCopyText to it's own export for easier testing

* fix MDXCode mock

* chore(react-native): Add callouts for dropped Expo Go support (#7160)

* Update index.mdx (#7165)

* Update github link to maplibre repo (#7162)

* Cbonif/add-sql-support-for-secrets-manager (#7104)

* add image example for secrets manager key/value

* add documentation for creating secrets in secrets manager and configuring db details on the construct

* adjust order of paragraphs, moving relevant text closer to image and make alt text more descriptive

* Fixed typo in amplifyconfiguration.json for predictions (#7185)

* fix swift docs to use the `.update` call (#7191)

* Update index.mdx (#7164)

* Added documentation on updated IAM behavior (#7056)

* Added documentation on updated IAM behavior

* Update src/pages/[platform]/tools/cli/migration/iam-auth-updates-for-cdk-construct/index.mdx

Co-authored-by: Kamil Sobol <sobol.k.r@gmail.com>

* Update src/pages/[platform]/build-a-backend/graphqlapi/customize-authorization-rules/index.mdx

Co-authored-by: Kamil Sobol <sobol.k.r@gmail.com>

* Update src/pages/[platform]/build-a-backend/graphqlapi/customize-authorization-rules/index.mdx

* Update src/pages/[platform]/tools/cli/migration/iam-auth-updates-for-cdk-construct/index.mdx

* Update src/pages/[platform]/tools/cli/migration/iam-auth-updates-for-cdk-construct/index.mdx

Co-authored-by: Tim Schmelter <schmelte@amazon.com>

* addressed comments

* Updated to reflect changes to Gen 2 content

* Update src/pages/[platform]/build-a-backend/graphqlapi/customize-authorization-rules/index.mdx

---------

Co-authored-by: Kamil Sobol <sobol.k.r@gmail.com>
Co-authored-by: Tim Schmelter <schmelte@amazon.com>

* Added Metadata section in Storage (#7152)

* Cbonif/edits-to-secondary-indexes-page (#7179)

* edits to custom business logic

* update secondary index code examples

* Add client examples of accessing models with specific auth modes (#7080)

* add client side code for public access

* add client side code for signed in user access

* add client side code for multi user access

* add client side code for per user/owner access

* add client side code for custom id & group claims

* add client side code for custom access

* add client side code for user pool group access

* add client side code for oidc access

* Update src/pages/gen2/build-a-backend/data/customize-authz/signed-in-user-data-access/index.mdx

Co-authored-by: Rene Brandel <4989523+renebrandel@users.noreply.github.com>

* add info callout and configuration code to public/private iam examples

* move callout up

* remove "**note**" from callouts

---------

Co-authored-by: Rene Brandel <4989523+renebrandel@users.noreply.github.com>

* adjustments to files merged from main

* Update Layout.tsx

* fix merge errors

* Update index.mdx

---------

Co-authored-by: Jim Eagan <84857865+hibler13@users.noreply.github.com>
Co-authored-by: Kevin Old <kevold@amazon.com>
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
Co-authored-by: Ankit Shah <22114629+ankpshah@users.noreply.github.com>
Co-authored-by: katiegoines <katiegoines@gmail.com>
Co-authored-by: Dan Kiuna <dankiuna@gmail.com>
Co-authored-by: Kihara, Takuya <gray@tacck.net>
Co-authored-by: Tyler Roach <tjroach@amazon.com>
Co-authored-by: Tim Nguyen <54393192+timngyn@users.noreply.github.com>
Co-authored-by: Rene Brandel <4989523+renebrandel@users.noreply.github.com>
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
Co-authored-by: Heather Buchel <hbuchel@gmail.com>
Co-authored-by: John Corser <johnpc@umich.edu>
Co-authored-by: Heather Pundt <119376175+heatheramz@users.noreply.github.com>
Co-authored-by: Nikhil Swaminathan <2429410+swaminator@users.noreply.github.com>
Co-authored-by: Jay Raval <jay.ambrish.raval@gmail.com>
Co-authored-by: David McAfee <mcafd@amazon.com>
Co-authored-by: Kethan sai <ykethan@amazon.com>
Co-authored-by: Michael Law <1365977+lawmicha@users.noreply.github.com>
Co-authored-by: erinleigh90 <106691284+erinleigh90@users.noreply.github.com>
Co-authored-by: Edward Foyle <foyleef@amazon.com>
Co-authored-by: Adi <34354177+the1adi@users.noreply.github.com>
Co-authored-by: Aditya Shahani <theadi@amazon.com>
Co-authored-by: josef <josef.aidt@gmail.com>
Co-authored-by: jacoblogan <jacob.maiola.logan@gmail.com>
Co-authored-by: Jacob Logan <lognjc@amazon.com>
Co-authored-by: Scott Rees <6165315+reesscot@users.noreply.github.com>
Co-authored-by: Chris Bonifacio <christopher.bonifacio@gmail.com>
Co-authored-by: Roshane Pascual <rtpascual@users.noreply.github.com>
Co-authored-by: Charles Shin <shin.charles11@gmail.com>
Co-authored-by: Ujjwol Shrestha <usewall05@gmail.com>
Co-authored-by: Gen Tamura <gen.tamura84@gmail.com>
Co-authored-by: dwittle <72715628+dwittle@users.noreply.github.com>
Co-authored-by: Anil Maktala <maktala.anil@gmail.com>
Co-authored-by: israx <70438514+israx@users.noreply.github.com>
Co-authored-by: Hui Zhao <10602282+HuiSF@users.noreply.github.com>
Co-authored-by: Nairi Areg <51801223+NairiAreg@users.noreply.github.com>
Co-authored-by: spivakov83 <spivakov83@gmail.com>
Co-authored-by: Harshita Daddala <harshita.d11@gmail.com>
Co-authored-by: derrik <fleminde@mail.gvsu.edu>
Co-authored-by: derrik.fleming <derrik.fleming@spindance.com>
Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
Co-authored-by: Kamil Sobol <sobol.k.r@gmail.com>
Co-authored-by: Tim Schmelter <schmelte@amazon.com>
Co-authored-by: yuhengshs <94558971+yuhengshs@users.noreply.github.com>
  • Loading branch information
Show file tree
Hide file tree
Showing 18 changed files with 602 additions and 123 deletions.
3 changes: 3 additions & 0 deletions src/directory/directory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,9 @@ export const directory = {
},
{
path: 'src/pages/gen1/[platform]/tools/cli/migration/identity-claim-changes/index.mdx'
},
{
path: 'src/pages/gen1/[platform]/tools/cli/migration/iam-auth-updates-for-cdk-construct/index.mdx'
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ For now, just add this method to the `onCreate` method of MainActivity with what
<Block name="Java">

```java
// Replace facebook with your chosen auth provider such as google, amazon, or apple
Amplify.Auth.signInWithSocialWebUI(
AuthProvider.facebook(),
AuthProvider.facebook(),
this,
result -> Log.i("AuthQuickstart", result.toString()),
error -> Log.e("AuthQuickstart", error.toString())
Expand All @@ -16,8 +17,9 @@ Amplify.Auth.signInWithSocialWebUI(
<Block name="Kotlin - Callbacks">

```kotlin
// Replace facebook with your chosen auth provider such as google, amazon, or apple
Amplify.Auth.signInWithSocialWebUI(
AuthProvider.facebook(),
AuthProvider.facebook(),
this,
{ Log.i("AuthQuickstart", "Sign in OK: $it") },
{ Log.e("AuthQuickstart", "Sign in failed", it) }
Expand All @@ -29,6 +31,7 @@ Amplify.Auth.signInWithSocialWebUI(

```kotlin
try {
// Replace facebook with your chosen auth provider such as google, amazon, or apple
val result = Amplify.Auth.signInWithSocialWebUI(AuthProvider.facebook(), this)
Log.i("AuthQuickstart", "Sign in OK: $result")
} catch (error: AuthException) {
Expand All @@ -40,6 +43,7 @@ try {
<Block name="RxJava">

```java
// Replace facebook with your chosen auth provider such as google, amazon, or apple
RxAmplify.Auth.signInWithSocialWebUI(AuthProvider.facebook(), this)
.subscribe(
result -> Log.i("AuthQuickstart", result.toString()),
Expand Down
136 changes: 132 additions & 4 deletions src/fragments/lib/storage/android/upload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To upload data to S3 from an `InputStream`:
private void uploadInputStream() {
try {
InputStream exampleInputStream = getContentResolver().openInputStream(uri);

Amplify.Storage.uploadInputStream(
"ExampleKey",
exampleInputStream,
Expand Down Expand Up @@ -61,10 +61,10 @@ private suspend fun uploadInputStream(uri: Uri) {
private void uploadInputStream() {
try {
InputStream exampleInputStream = getContentResolver().openInputStream(uri);

RxProgressAwareSingleOperation<StorageUploadInputStreamResult> rxUploadOperation =
RxAmplify.Storage.uploadInputStream("ExampleKey", exampleInputStream);

rxUploadOperation
.observeResult()
.subscribe(
Expand All @@ -81,7 +81,7 @@ private void uploadInputStream() {
</BlockSwitcher>

## Upload files
To upload to S3 from a data object, specify the key and the file to be uploaded.
To upload to S3 from a data object, specify the key and the file to be uploaded.

<BlockSwitcher>
<Block name="Java">
Expand Down Expand Up @@ -257,6 +257,134 @@ upload
</Block>
</BlockSwitcher>

## Transfer with Object Metadata

To upload a file accompanied by metadata, utilize the `StorageUploadFileOptions` builder. Start by creating a hashMap object, then incorporate it into the `StorageUploadFileOptions` during the build process before passing it along to the upload function.
<BlockSwitcher>
<Block name="Java">
```java
private void uploadFile() {
File exampleFile = new File(getApplicationContext().getFilesDir(), "ExampleKey");
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(exampleFile));
writer.append("Example file contents");
writer.close();
} catch (Exception exception) {
Log.e("MyAmplifyApp", "Upload failed", exception);
}

// Create metadata
Map<String, String> userMetadata = new HashMap<>();
userMetadata.put("myKey", "myVal");

// Configure upload options with metadata
StorageUploadFileOptions options = StorageUploadFileOptions.builder()
.metadata(userMetadata)
.build();

// Perform the upload
Amplify.Storage.uploadFile(
"ExampleKey",
exampleFile,
options,
result -> Log.i("MyAmplifyApp", "Successfully uploaded: " + result.getKey()),
error -> Log.e("MyAmplifyApp", "Upload failed", error)
);
}
```
</Block>
<Block name="Kotlin - Callbacks">
```kotlin
fun uploadFile() {
val exampleFile = File(applicationContext.filesDir, "ExampleFileName")
exampleFile.writeText("Example file contents")

// Create metadata
val userMetadata: MutableMap<String, String> = HashMap()
userMetadata["myKey"] = "myVal"

// Configure upload options with metadata
val options = StorageUploadFileOptions.builder()
.metadata(userMetadata)
.build()

// Perform the upload
Amplify.Storage.uploadFile(
"ExampleKey",
exampleFile,
options,
{ result -> Log.i("MyAmplifyApp", "Successfully uploaded: ${result.key}") },
{ error -> Log.e("MyAmplifyApp", "Upload failed", error) }
)
}
```
</Block>
<Block name="Kotlin - Coroutines">
```kotlin
fun uploadFile() {
val exampleFile = File(applicationContext.filesDir, "ExampleFileName")
exampleFile.writeText("Example file contents")

// Create metadata
val userMetadata: MutableMap<String, String> = HashMap()
userMetadata["myKey"] = "myVal"

// Configure upload options with metadata
val options = StorageUploadFileOptions.builder()
.metadata(userMetadata)
.build()

val upload = Amplify.Storage.uploadFile("ExampleKey", exampleFile, options)
val progressJob = activityScope.async {
upload.progress().collect {
Log.i("MyAmplifyApp", "Fraction completed: ${it.fractionCompleted}")
}
}
try {
val result = upload.result()
Log.i("MyAmplifyApp", "Successfully uploaded: ${result.key}")
} catch (error: StorageException) {
Log.e("MyAmplifyApp", "Upload failed", error)
}
progressJob.cancel()
}
```
</Block>
<Block name="RxJava">
```Java
private void uploadFile() {
File exampleFile = new File(getApplicationContext().getFilesDir(), "ExampleKey");

try {
BufferedWriter writer = new BufferedWriter(new FileWriter(exampleFile));
writer.append("Example file contents");
writer.close();
} catch (Exception exception) {
Log.e("MyAmplifyApp", "Upload failed", exception);
}

Map<String, String> userMetadata = new HashMap<>();
userMetadata.put("myKey", "myVal");

StorageUploadFileOptions options = StorageUploadFileOptions.builder()
.metadata(userMetadata)
.build();

RxStorageBinding.RxProgressAwareSingleOperation<StorageUploadFileResult> rxUploadOperation =
RxAmplify.Storage.uploadFile("ExampleKey", exampleFile, options);

rxUploadOperation
.observeResult()
.subscribe(
result -> Log.i("MyAmplifyApp", "Successfully uploaded: " + result.getKey()),
error -> Log.e("MyAmplifyApp", "Upload failed", error)
);
}
```
</Block>
</BlockSwitcher>


## MultiPart upload

Amplify will automatically perform a S3 multipart upload for objects that are larger than 5MB. For more information about S3's multipart upload, see [Uploading and copying objects using multipart upload](https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html)
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const client = generateClient<Schema>({
```

</Block>
<Block name="AWS IAM">
<Block name="AWS IAM (including Amazon Cognito identity pool roles)">

```ts
import { generateClient } from 'aws-amplify/data';
Expand Down Expand Up @@ -179,7 +179,7 @@ const { data: todos, errors } = await client.models.Todo.list({
```

</Block>
<Block name="AWS IAM">
<Block name="AWS IAM (including Amazon Cognito identity pool roles)">

```ts
const { data: todos, errors } = await client.models.Todo.list({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Amplify Data supports using custom identity and group claims if you do not wish

To use custom claims specify `identityClaim` or `groupClaim` as appropriate. In the example below, the `identityClaim` is specified and the record owner will check against this `user_id` claim. Similarly, if the `user_groups` claim contains a "Moderator" string then access will be granted.

```ts
```ts title="amplify/data/resource.ts"
import { a, defineData, type ClientSchema } from '@aws-amplify/backend';

const schema = a.schema({
Expand All @@ -54,3 +54,24 @@ export type Schema = ClientSchema<typeof schema>;
export const data = defineData({ schema });

```

In your application, you can perform CRUD operations against the model using `client.models.<model-name>` with the `userPool` auth mode.

```ts
import { generateClient } from 'aws-amplify/data';
import type { Schema } from '../amplify/data/resource'; // Path to your backend resource definition

const client = generateClient<Schema>();

const { errors, data: newTodo } = await client.models.Todo.create(
{
postname: 'My New Post'
content: 'My post content',
},
// highlight-start
{
authMode: 'userPool',
}
// highlight-end
);
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function getStaticProps(context) {

You can define your own custom authorization rule with a Lambda function.

```ts
```ts title="amplify/data/resource.ts"
import {
type ClientSchema,
a,
Expand Down Expand Up @@ -68,6 +68,26 @@ export const data = defineData({
});
```

In your application, you can perform CRUD operations against the model using `client.models.<model-name>` with the `lambda` auth mode.

```ts
import { generateClient } from 'aws-amplify/data';
import type { Schema } from '../amplify/data/resource'; // Path to your backend resource definition

const client = generateClient<Schema>();

const { errors, data: newTodo } = await client.models.Todo.create(
{
content: 'My new todo',
},
// highlight-start
{
authMode: 'lambda',
}
// highlight-end
);
```

The Lambda function of choice will receive an authorization token from the client and execute the desired authorization logic. The AppSync GraphQL API will receive a payload from Lambda after invocation to allow or deny the API call accordingly.

To configure a Lambda function as the authorization mode, create a new file `amplify/data/custom-authorizer.ts`. You can use this Lambda function code template as a starting point for your authorization handler code:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ Use the guide below to select the correct authorization strategy for your use ca
| **Recommended use case** | **Strategy** | **Provider** |
|---|---|---|
| [Public data access where users or devices are anonymous. Anyone with the AppSync API key is granted access.](/[platform]/build-a-backend/data/customize-authz/public-data-access) | `public` | `apiKey` |
| [Recommended for production environment's public data access. Public data access where unauthenticated users or devices are granted permissions using AWS IAM controls.](/[platform]/build-a-backend/data/customize-authz/public-data-access/#add-public-authorization-rule-using-iam-authentication) | `public` | `iam` |
| [Recommended for production environment's public data access. Public data access where unauthenticated users or devices are granted permissions using Amazon Cognito identity pool's role for unauthenticated identities.]( /[platform]/build-a-backend/data/customize-authz/public-data-access/#add-public-authorization-rule-using-iam-authentication) | `public` | `identityPool` |
| [Per user data access. Access is restricted to the "owner" of a record. Leverages `amplify/auth/resource.ts` Cognito user pool by default.](/[platform]/build-a-backend/data/customize-authz/per-user-per-owner-data-access) | `owner` | `userPools` / `oidc` |
| [Any signed-in data access. Unlike owner-based access, **any** signed-in user has access.](/[platform]/build-a-backend/data/customize-authz/signed-in-user-data-access) | `private` | `userPools` / `oidc` / `iam` |
| [Any signed-in data access. Unlike owner-based access, **any** signed-in user has access.](/[platform]/build-a-backend/data/customize-authz/signed-in-user-data-access) | `private` | `userPools` / `oidc` / `identityPool` |
| [Per user group data access. A specific or dynamically configured group of users has access.](/[platform]/build-a-backend/data/customize-authz/user-group-based-data-access) | `group` | `userPools` / `oidc` |
| [Define your own custom authorization rule within a serverless function.](/[platform]/build-a-backend/data/customize-authz/custom-data-access-patterns) | `custom` | `function` |

Expand All @@ -71,8 +71,6 @@ Amplify will always use the most specific authorization rule that is available.

If there are multiple authorization rules present, they will be logically OR'ed. Review [Configure multiple authorization rules](#configure-multiple-authorization-rules) to learn more.

Finally, there are special "Admin IAM Roles" that allow you to overrule any authorization logic applied on the API and determine the API access completely via its IAM policy.

### Global authorization rule (only for getting started)

To help you get started, you can define an authorization rule on the data schema that will be applied to all data models that **do not** have a model-level authorization rule. Instead of having a global authorization rule for all production environments, we recommend creating specific authorization rules for each model or field.
Expand Down Expand Up @@ -149,7 +147,7 @@ const schema = a.schema({
### Configure multiple authorization rules

When combining multiple authorization rules, they are "logically OR"-ed. In the following example:
- Any user (signed in or not, verified by IAM) is allowed to read all posts
- Any user (using Amazon Cognito identity pool's unauthenticated roles) is allowed to read all posts
- Owners are allowed to create, read, update, and delete their own posts

```ts
Expand All @@ -158,7 +156,7 @@ const schema = a.schema({
title: a.string(),
content: a.string()
}).authorization([
a.allow.public("iam").to(["read"]),
a.allow.public("identityPool").to(["read"]),
a.allow.owner()
])
})
Expand All @@ -179,7 +177,7 @@ const { data: newPostResult , errors } = await client.models.Post.create({
authMode: 'userPool',
});

// Listing posts is available to all users (verified by IAM)
// Listing posts is available to unauthenticated users (verified by Amazon Cognito identity pool's unauthenticated role)
const { data: listPostsResult , errors } = await client.models.Post.list({
query: queries.listPosts,
authMode: 'iam',
Expand Down
Loading

0 comments on commit 67c6dd5

Please sign in to comment.