浏览我们的产品

If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.


Product Docs Swagger Examples Blog Support Dashboard

安装

该软件包在PyPI可用,可以通过执行以下命令通过pip安装:

pip install groupdocs-metadata-cloud

PyPI - Version PyPI - Downloads Python-GroupDocsCloud


要求

依赖关系

SDK自动安装以下软件包:

PackageConstraint
urllib3>= 1.15
six>= 1.10
certifi
python-dateutil

快速入门

获取您的 API 凭证

要使用GroupDocs.Metadata Cloud,请在GroupDocs.Cloud仪表板注册并获取您的Client IDClient Secret

初始化API

使用以下代码开始使用GroupDocs.Metadata Cloud SDK for Python:

import groupdocs_metadata_cloud

# Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud
client_id = "YourClientId"
client_secret = "YourClientSecret"

# Create API configuration
configuration = groupdocs_metadata_cloud.Configuration(client_id, client_secret)
configuration.api_base_url = "https://api.groupdocs.cloud"

# Create instance of the Metadata API
metadata_api = groupdocs_metadata_cloud.MetadataApi.from_config(configuration)

从文档中提取元数据

初始化后,使用此基本示例从云存储中的文件中提取元数据:

import groupdocs_metadata_cloud

client_id = "YourClientId"
client_secret = "YourClientSecret"

metadata_api = groupdocs_metadata_cloud.MetadataApi.from_keys(client_id, client_secret)

options = groupdocs_metadata_cloud.ExtractOptions()
options.file_info = groupdocs_metadata_cloud.FileInfo()
options.file_info.file_path = "documents/sample.docx"

request = groupdocs_metadata_cloud.ExtractRequest(options)
result = metadata_api.extract(request)

print("Metadata extracted successfully")

通过本快速入门指南,您已准备好开始在 Python 应用程序中使用 GroupDocs.Metadata Cloud 管理元数据。欲了解更多详情,请访问文档

获取支持的文件格式

通过元数据 API 检索可用的受支持文件格式的完整列表。

import groupdocs_metadata_cloud

info_api = groupdocs_metadata_cloud.InfoApi.from_keys("YourClientId", "YourClientSecret")

result = info_api.get_supported_file_formats()

for fmt in result.formats:
    print("{0} ({1})".format(fmt.file_format, fmt.extension))

通过标签提取元数据

从文档中提取与特定标签匹配的元数据属性。

import groupdocs_metadata_cloud

metadata_api = groupdocs_metadata_cloud.MetadataApi.from_keys("YourClientId", "YourClientSecret")

options = groupdocs_metadata_cloud.ExtractOptions()
options.file_info = groupdocs_metadata_cloud.FileInfo()
options.file_info.file_path = "documents/sample.docx"
options.search_criteria = groupdocs_metadata_cloud.SearchCriteria(
    tag_options=groupdocs_metadata_cloud.TagOptions(
        exact_tag=groupdocs_metadata_cloud.Tag(
            name="Created",
            category="Time"
        )
    )
)

request = groupdocs_metadata_cloud.ExtractRequest(options)
result = metadata_api.extract(request)

print("Properties found: " + str(len(result.properties)))

添加自定义元数据

使用基于标签的搜索条件向文档添加新的元数据属性。

import groupdocs_metadata_cloud

metadata_api = groupdocs_metadata_cloud.MetadataApi.from_keys("YourClientId", "YourClientSecret")

options = groupdocs_metadata_cloud.AddOptions()
options.file_info = groupdocs_metadata_cloud.FileInfo()
options.file_info.file_path = "documents/sample.docx"

add_property = groupdocs_metadata_cloud.AddProperty(
    value="Test User",
    type="String",
    search_criteria=groupdocs_metadata_cloud.SearchCriteriaWithoutValue(
        tag_options=groupdocs_metadata_cloud.TagOptions(
            exact_tag=groupdocs_metadata_cloud.Tag(
                name="Manager",
                category="Person"
            )
        )
    )
)
options.properties = [add_property]

request = groupdocs_metadata_cloud.AddRequest(options)
result = metadata_api.add(request)

print("Added count: " + str(result.added_count))

修改元数据属性

按标签、名称或值搜索条件更新现有元数据属性。

import groupdocs_metadata_cloud

metadata_api = groupdocs_metadata_cloud.MetadataApi.from_keys("YourClientId", "YourClientSecret")

options = groupdocs_metadata_cloud.SetOptions()
options.file_info = groupdocs_metadata_cloud.FileInfo()
options.file_info.file_path = "documents/sample.docx"

set_property = groupdocs_metadata_cloud.SetProperty(
    new_value="NewAuthor",
    type="String",
    search_criteria=groupdocs_metadata_cloud.SearchCriteria(
        tag_options=groupdocs_metadata_cloud.TagOptions(
            exact_tag=groupdocs_metadata_cloud.Tag(
                name="Creator",
                category="Person"
            )
        )
    )
)
options.properties = [set_property]

request = groupdocs_metadata_cloud.SetRequest(options)
result = metadata_api.set(request)

print("Set count: " + str(result.set_count))

删除元数据属性

根据搜索条件从文档中删除元数据属性。

import groupdocs_metadata_cloud

metadata_api = groupdocs_metadata_cloud.MetadataApi.from_keys("YourClientId", "YourClientSecret")

options = groupdocs_metadata_cloud.RemoveOptions()
options.file_info = groupdocs_metadata_cloud.FileInfo()
options.file_info.file_path = "documents/sample.docx"
options.search_criteria = groupdocs_metadata_cloud.SearchCriteria(
    tag_options=groupdocs_metadata_cloud.TagOptions(
        exact_tag=groupdocs_metadata_cloud.Tag(
            name="Created",
            category="Time"
        )
    )
)

request = groupdocs_metadata_cloud.RemoveRequest(options)
result = metadata_api.remove(request)

print("Removed count: " + str(result.removed_count))

获取文档信息

在处理元数据之前检索文档详细信息,例如格式、大小和页数。

import groupdocs_metadata_cloud

info_api = groupdocs_metadata_cloud.InfoApi.from_keys("YourClientId", "YourClientSecret")

options = groupdocs_metadata_cloud.InfoOptions()
options.file_info = groupdocs_metadata_cloud.FileInfo()
options.file_info.file_path = "documents/sample.pptx"

request = groupdocs_metadata_cloud.GetInfoRequest(options)
result = info_api.get_info(request)

print("Document info retrieved successfully")

GitHub 上的 SDK 示例

GroupDocs.Metadata Cloud Python SDK 存储库在 test/apis 文件夹中包含单元测试和 API 使用示例:

CategoryExamples
Metadata OperationsExtract, add, set, remove metadata by tag, name, or value
Info OperationsSupported file formats, document information
Storage & FilesStorage API, file upload/download, folder management
AuthenticationAPI configuration and authentication

.NET 示例存储库 中提供了其他基于场景的示例。

如何运行 SDK 测试

  1. 克隆Python SDK存储库 2.安装依赖:pip install groupdocs-metadata-cloud
  2. test/test_settings.py中配置凭证
  3. 从存储库根运行测试:python -m unittest discover test

欲了解更多详情,请访问入门


Product Docs Swagger Examples Blog Support Dashboard


标签

Document Metadata API | Python Cloud API | GroupDocs.Metadata Cloud | REST API | Metadata Extraction | Metadata Management | Metadata Filtering | Metadata Searching | Metadata Preservation | Cloud Storage Integration | File Management | Folder Management | File Versioning | Secure API Access | Cross-Platform API | PDF Metadata | Image Metadata | Video Metadata | Audio Metadata | Document Metadata Editing | MIT License



 简体中文