Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

amazon web services - Is there a way to share a document in Workdocs via the Workdocs API?

as far as i know i can share or download a document in Workdocs via the Amazon Workdocs UI. I am trying to build a static website in a S3 bucket that offers a Link to a Workdoc document for download.

Thus i have to share this document after verifying some stuff. Sadly i found nothing similiar in the API documentation (https://docs.aws.amazon.com/workdocs/latest/APIReference/workdocs-api.pdf).

NodeJs would be fine using JDK but i can also try to use lambda functions if necessary.

Greetings,

Eric

question from:https://stackoverflow.com/questions/65940686/is-there-a-way-to-share-a-document-in-workdocs-via-the-workdocs-api

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can build AWS python3+ based AWS Lambda along with 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...