amazon-web-services - 有没有办法通过 Workdocs API 在 Workdocs 中共享文档?
问题描述
据我所知,我可以通过 Amazon Workdocs UI 在 Workdocs 中共享或下载文档。我正在尝试在 S3 存储桶中构建一个静态网站,该网站提供指向 Workdoc 文档的链接以供下载。
因此,我必须在验证一些内容后分享此文档。遗憾的是,我在 API 文档( https://docs.aws.amazon.com/workdocs/latest/APIReference/workdocs-api.pdf)中没有发现任何类似的东西。
NodeJs 使用 JDK 会很好,但如果需要,我也可以尝试使用 lambda 函数。
问候,
埃里克
解决方案
您可以构建基于 AWS python3+ 的 AWS Lambda 以及 AWS Step Functions。
import boto3
work_docs_client = boto3.client('workdocs') # Change aws connection parameters as per your setup
def lambda_handler(event, context):
# Call share_document_work_docs(resource_id, recipient_id) based on your conditions/checks
return None # change this as per your use-case
# This will add the permissions to the document to share
def share_document_work_docs(resource_id, recipient_id):
principals = [{'Id': recipient_id, 'Type': 'USER', 'Role': 'VIEWER'}] # change this as per your use-case
share_doc_response = work_docs_client.add_resource_permissions(
ResourceId=resource_id,
Principals=principals,
NotificationOptions={
'SendEmail': True,
'EmailMessage': 'Your message here',
} # change NotificationOptions as per your use-case
)
return share_doc_response
推荐阅读
- excel - 为什么单击保存按钮时我的 vba 用户窗体会崩溃?
- java - Mapstruct - 忽略集合内的属性
- python - 使用 selenium 使用 python 获取当前日期的全尺寸屏幕截图
- javascript - Node.js/MongoDB 执行多关键字搜索
- kubernetes - 如何使用 terraform 从 S3 加载 kubeconfig 文件
- python - 使用 Flask-SQLAlchemy 将 Python zip() 列表加载到 SQLite DB
- php - 使用 Sanctum 的 Laravel 7 SPA API 身份验证
- java - JNA 将等效的 swift 指针从 Java Android 传递给 C
- swift - 从静态变量访问实例函数
- visual-studio-code - 如何防止为远程 ssh 连接启动新的 VS Code 窗口