Skip to content

stanwood/stanwood-services

Repository files navigation

Stanwood services

Contains various services used in stanwood.

Includes:

Usage

PDF service

Split PDF with multiple pages into separate images

curl https://<project_name>.appspot.com/pdf/v1/<quoted_pdf_url>

Get first page of PDF as image

curl -L "https://<project_name>.appspot.com/pdf/v1/<quoted_pdf_url>/pages/1.<image_extension:png,jpg,...>"

Image service

Create bucket and token for it

I recommend to open it in browser with logged in GCP account.

curl https://<project_name>.appspot.com/<namespace>/tokens 

Response:

{
    'namespace': '<namespace>',
    'token': 'XXXXXXXXXXXXX'
}

Store and cache image with auth header

curl -L "https://<project_name>.appspot.com/image?url=<image_url>" -H "X-Auth-Token: <token>" > "<image_name>"

Resize image

curl -L "https://<project_name>.appspot.com/image?url=<image_url>&width=1024" -H "X-Auth-Token: <token>" > "<image_name>"

Crop image

curl -L "https://<project_name>.appspot.com/image?url=<image_url>&crop=200,200,400,400" -H "X-Auth-Token: <token>" > "<image_name>"

QR code service

Get QR code url as url field in JSON response with lowest size

curl -X GET "https://your-app-id.appspot.com/generate?data=https%3A%2F%2Fstanwood.io&format=json&version=1

Get QR code url as location in redirect response with highest size

curl -X GET "https://your-app-id.appspot.com/generate?data=https%3A%2F%2Fstanwood.io&version=40

Get QR code direct image

curl -X GET "https://your-app-id.appspot.com/generate?data=https%3A%2F%2Fstanwood.io&format=image

Note

  • The version parameter is an integer from 1 to 40 that controls the size of the QR Code (the smallest, version 1, is a 21x21 matrix).

Mock API service

Get file content by sending GET request from default branch (usually master)

$ curl -X GET \
    "https://<PROJECT_ID>.appspot.com/v1/mock/<ORGANIZATION_NAME>/<REPO_NAME>/contents/<PATH_TO_FILE>"

Get file content by sending GET request from selected branch/tag/commit

$ curl -X GET \
    "https://<PROJECT_ID>.appspot.com/v1/mock/<ORGANIZATION_NAME>/<REPO_NAME>/contents/<PATH_TO_FILE>?ref=<REF_NAME>"

Get file content by sending mock request (any HTTP method)

$ curl -X GET/POST/DELETE/PUT/PATCH/... \
    --data '{"happy": true}' \
    -H "Content-Type: application/json" \
    "https://<PROJECT_ID>.appspot.com/v1/mock/<ORGANIZATION_NAME>/<REPO_NAME>/contents/<PATH_TO_FILE>"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published