Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get all assets from azure media service #669

Closed
kennethinsnow opened this issue Apr 22, 2016 · 2 comments
Closed

How do I get all assets from azure media service #669

kennethinsnow opened this issue Apr 22, 2016 · 2 comments

Comments

@kennethinsnow
Copy link

kennethinsnow commented Apr 22, 2016

One query returns a maximum of 1000 items. how do i get the rest of them? Does java sdk provides a way to skip like this php program?
https://blogs.msdn.microsoft.com/randomnumber/2015/11/05/listing-more-than-1000-assets-with-the-php-sdk-for-azure-media-services/
My code:
MediaContract mediaService = MediaService.create(MediaConfiguration.configureWithOAuthAuthentication( mediaServiceUri, oAuthUri, AMSAccountName, AMSAccountKey, scope));
List<AssetInfo> info = mediaService.list(Asset.list());
Thanks,

@kennethinsnow
Copy link
Author

Here is my own solution after getting some help from stackoverflow

        List<AssetInfo> allAssets = new ArrayList<>();
        int skip = 0;
        while (true) {
            List<AssetInfo> curAssets = mediaService.list(getAllAssetPage(skip));
            if (curAssets.size() > 0) {
                allAssets.addAll(curAssets);
                if (curAssets.size() == 1000) {
                    System.out.println(String.format("Got %d assets.", allAssets.size()));
                    skip += 1000;
                } else {
                    break;
                }
            } else {
                break;
            }
        }
        private static DefaultListOperation<AssetInfo> getAllAssetPage(int skip) {
            return new DefaultListOperation<AssetInfo>("Assets",
            new GenericType<ListResult<AssetInfo>>() {
            }).setSkip(skip);
        }

@jianghaolu
Copy link
Contributor

Hi @kennethinsnow

Thanks for sharing your solution!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants