Skip to content

idea2app/idea-lark-r2

Repository files navigation

idea2app-Lark-R2

This Cloudflare worker uploads images synchronously from Lark base to R2 object storage. To utilize this functionality, you need to set up a Lark base workflow which sends an HTTP request to the worker. Subsequently, the worker retrieves the image from Lark and transfers it to R2.

CI & CD Open in GitHub Codespaces Open in Gitpod Deploy to Cloudflare Workers

Preset

Cloudflare authentication

You'll need to configure Wrangler using GitHub's Secrets feature - go to "Settings -> Secrets" and add your Cloudflare API token (for help finding this, see the Workers documentation). Your API token is encrypted by GitHub, and the action won't print it into logs, so it should be safe!

Lark config

  1. Create an workflow

  2. Custom trigger Select the field where the image is located, use the image modification as a trigger condition

  1. Send an HTTP request Your HTTP request should resemble the following: POST https://BUCKET_BASE_URL/lark?file_token=REDACTED&name=hello.png&type=image%2Fpng There for, you are required to include the file_token, name and type fields in your query parameters

[lark base tutorial]

GitHub Actions configuration

Configure GitHub Actions variables to trigger automated deployments after each push.

# https://developers.cloudflare.com/workers/ci-cd/external-cicd/#api-token
apiToken:
secrets: |
# [en] https://open.larksuite.com/document/home/interactive-message-card-sending/create-app-request-permission
    LARK_ID
    LARK_SECRET
# Auth with custom header (X-Lark-Upload-Token)
    LARK_UPLOAD_KEY
vars: |
# default to be https://open.larksuite.com/open-apis/
    LARK_HOST
# your Bucket base URL, which you can set later with custom domains
    BUCKET_BASE_URL
npm i pnpm -g

pnpm i

npm start

Deployment

pnpm deploy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published