docs icon indicating copy to clipboard operation
docs copied to clipboard

docs (JS Storage Update for paginated listing of files) Updating the file src/pages/gen1/[platform]/build-a-backend/storage/list/index.mdx

Open subhayum-amplify opened this issue 7 months ago • 0 comments

Description of changes:

Hi Team updated the src/pages/gen1/[platform]/build-a-backend/storage/list/index.mdx file for the section

import { list } from 'aws-amplify/storage';

const PAGE_SIZE = 20;
let nextToken = undefined;
//...
const loadNextPage = async () => {
  let response = await list({
    path: 'public/photos/',
    // Alternatively, path: ({identityId}) => `protected/${identityId}/photos/`
    pageSize: PAGE_SIZE,
    nextToken: nextToken
    }
  });
  if (response.nextToken) {
    nextToken = response.nextToken;
  } else {
    nextToken = undefined;
  }
  // render list items from response.items
};

to

import { list } from 'aws-amplify/storage';

const PAGE_SIZE = 20;
let nextToken = undefined;
//...
const loadNextPage = async () => {
  let response = await list({
    path: 'public/photos/',
    // Alternatively, path: ({identityId}) => `protected/${identityId}/photos/`
    options: {
      pageSize: PAGE_SIZE,
      nextToken: nextToken
    }
    }
  });
  if (response.nextToken) {
    nextToken = response.nextToken;
  } else {
    nextToken = undefined;
  }
  // render list items from response.items
};

Added the options block to ensure correct passing of pageSize and nextToken, as existing code, does not allow pagination. (tested at my end).

Related GitHub issue #, if available: No

Instructions

If this PR should not be merged upon approval for any reason, please submit as a DRAFT

Which product(s) are affected by this PR (if applicable)?

  • [ ] amplify-cli
  • [ ] amplify-ui
  • [ ] amplify-studio
  • [ ] amplify-hosting
  • [X ] amplify-libraries

Which platform(s) are affected by this PR (if applicable)?

  • [X ] JS
  • [ ] Swift
  • [ ] Android
  • [ ] Flutter
  • [ ] React Native

Please add the product(s)/platform(s) affected to the PR title

Checks

  • [ X] Does this PR conform to the styleguide?

  • [ ] Does this PR include filetypes other than markdown or images? Please add or update unit tests accordingly.

  • [ ] Are any files being deleted with this PR? If so, have the needed redirects been created?

  • [ ] Are all links in MDX files using the MDX link syntax rather than HTML link syntax?
    ref: MDX: [link](https://docs.amplify.aws/) HTML: <a href="https://docs.amplify.aws/">link</a>

When this PR is ready to merge, please check the box below

  • [ X] Ready to merge

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

subhayum-amplify avatar Jul 23 '24 08:07 subhayum-amplify