文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DescribeRootFolders
搭配 a AWS SDK 使用
下列程式碼範例示範如何使用 DescribeRootFolders
。
- Ruby
-
- Ruby 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 # Retrieves the root folder for a user by email # @param users [Array<Types::User>] A list of users selected from API response # @param user_email [String] The email of the user. def get_user_folder(users, user_email) user = users.find { |user| user.email_address == user_email } if user user.root_folder_id else @logger.error "Could not get root folder for user with email address #{user_email}" exit(1) end end # Describes the contents of a folder # @param [String] folder_id - The Id of the folder to describe. def describe_folder_contents(folder_id) resp = @client.describe_folder_contents({ folder_id: folder_id, # required sort: 'NAME', # accepts DATE, NAME order: 'ASCENDING' # accepts ASCENDING, DESCENDING }) resp.documents.each do |doc| md = doc.latest_version_metadata @logger.info "Name: #{md.name}" @logger.info "Size (bytes): #{md.size}" @logger.info "Last modified: #{doc.modified_timestamp}" @logger.info "Doc ID: #{doc.id}" @logger.info "Version ID: #{md.id}" @logger.info '' end rescue Aws::WorkDocs::Errors::ServiceError => e @logger.error "Error listing folder contents: #{e.message}" exit(1) end
-
如需 API 詳細資訊,請參閱 DescribeRootFolders AWS SDK for Ruby 參考中的 API。
-
動作
DescribeUsers