Skip to content

A Google Cloud Function that triggers on object creation in Cloud Storage and optimizes image with Kraken.io ๐Ÿ“โœ‚๏ธโœŒ๏ธ

License

Notifications You must be signed in to change notification settings

larsha/gcp-function-kraken

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

function.go

Google Cloud Function using Go 1.11 with modules. This function triggers on google.storage.object.finalize event and sends the file to Kraken.io to compress/optimize it then replaces the file in the bucket.

This function should be deployed where you want a decoupled image compression tool to react when images are saved to Google Cloud Storage in your application.

export BUCKET=""
export KRAKEN_API_KEY=""
export KRAKEN_SECRET_KEY=""
gcloud functions deploy ImageCompressor \
    --set-env-vars KRAKEN_API_KEY=$KRAKEN_API_KEY,KRAKEN_SECRET_KEY=$KRAKEN_SECRET_KEY \
    --region europe-west1 \
    --runtime go113 \
    --trigger-resource $BUCKET \
    --trigger-event google.storage.object.finalize

About

A Google Cloud Function that triggers on object creation in Cloud Storage and optimizes image with Kraken.io ๐Ÿ“โœ‚๏ธโœŒ๏ธ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages