Skip to main content

A thumbor server extension for DASH

Project description

thumbor_dash

A thumbor server extension for DASH

Setup

Requirements

  • Python >= 3.9
  • Pip >= 21.1
  • Thumbor == 7.0.0a5

See the requirements for setting up thumbor in the documentation

1. Install thumbor_dash

pip install thumbor_dash

Note: thumbor_dash, thumbor, and other required dependencies will be installed

2. Create a thumbor configuration file

thumbor-config > thumbor.conf

3. Add these lines to thumbor.conf file

# Set allowed dimensions
MIN_WIDTH = 1
MIN_HEIGHT = 1
MAX_WIDTH = 1200
MAX_HEIGHT = 800

# Use custom Url signing method (sha256)
URL_SIGNER = 'thumbor_dash.url_signers.base64_hmac_sha256'

# Allow only signed URL
ALLOW_UNSAFE_URL = False

# Set user moderation rules
REQUEST_TIME_LIMIT = 1 # time between requests in minutes
USAGE_VIOLATION_LIMIT = 5 # total number of times a requester can violate the time limit before ban
BAN_DURATION = 10 # requester ban duration in minutes

# Use custom error handling
USE_CUSTOM_ERROR_HANDLING = True
ERROR_HANDLER_MODULE = 'thumbor_dash.error_handlers.sentry'

# User-defined MN and IP list
SEED_IP = 'seed-1.testnet.networks.dash.org'
MN_LIST =  '34.219.81.129,34.221.42.205,34.208.88.128,54.189.162.193,34.220.124.90,54.201.242.241,54.68.10.46,34.210.81.39,18.237.47.243'

Usage

1. Start thumbor_dash server

thumbor_dash --conf=thumbor.conf

2. Sign image URL

thumbor_dash-url --key="<Requester Identity Key>" --width=<width> --height=<height> --dashauth="requester(<requesterId>):contract(<contractId>):document(<documentType>):field(<avatarUrl>):owner(<ownerId>):updatedAt(<updatedAt>)" --filters="<filters>" <imageURL>

output:

/<signature>/<width>x<height>/dashauth:requester(<requesterId>):contract(<contractId>):document(<documentType>):field(<field>):owner(<ownerId>):updatedAt(<updatedAt>)/filters:format(<format>)/<encodedImageUrl>

3. Thumbor_dash image retrieval URL

http://<thumbor_dash-server>/<signature>/<width>x<height>/dashauth:requester(<requesterId>):contract(<contractId>):document(<documentType>):field(<field>):owner(<ownerId>):updatedAt(<updatedAt>)/filters:format(<format>)/<encodedImageUrl>

Note: If running the server locally, <thumbor_dash-server> should be localhost:8888

Example

This is a signed thumbor_dash url. Simply run thumbor_dash and paste this link in your browser.

http://localhost:8888/U6lnOyBbSbRmZoxIgj81unAoR-V2GhJj1lAAQ0846Nw=/1200x800/dashauth:requester(856aSH6uEBaHpndZYXDk72NJbZqXokNSPGrs8nKbd7QL):contract(DbBHu3Ct1zD1AYAiw58V7QXT22B3k7qRLDLfaXqiRQp5):document(thumbnailField):field(avatarUrl):owner(856aSH6uEBaHpndZYXDk72NJbZqXokNSPGrs8nKbd7QL):updatedAt(1654864287788)/filters:format(jpeg)/https%3A//github.com/thumbor/thumbor/raw/master/example.jpg

Running thumbor_dash in Docker

This is the fastest way to run thumbor_dash

1. Create a thumbor.env.txt file containing the environment variables

MIN_WIDTH=1
MIN_HEIGHT=1
MAX_WIDTH=1200
MAX_HEIGHT=800
REQUEST_TIME_LIMIT=1 
USAGE_VIOLATION_LIMIT=5
BAN_DURATION=10
USE_CUSTOM_ERROR_HANDLING=True
ALLOW_UNSAFE_URL=False
URL_SIGNER=thumbor_dash.url_signers.base64_hmac_sha256
ERROR_HANDLER_MODULE=thumbor_dash.error_handlers.sentry
SEED_IP=seed-1.testnet.networks.dash.org
MN_LIST=34.219.81.129,34.221.42.205,34.208.88.128,54.189.162.193,34.220.124.90,54.201.242.241,54.68.10.46,34.210.81.39,18.237.47.243

2. Start thumbor_dash server in Docker

docker run -p 80:80 --env-file thumbor.env.txt mayoreee/thumbor_dash When your environment is not ARM-based, add the option --platform linux/arm64/v8

Note: If running in Docker, <thumbor_dash-server> in the image request URL should be set to localhost:80 instead of localhost:8888.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thumbor_dash-0.0.20.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

thumbor_dash-0.0.20-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file thumbor_dash-0.0.20.tar.gz.

File metadata

  • Download URL: thumbor_dash-0.0.20.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for thumbor_dash-0.0.20.tar.gz
Algorithm Hash digest
SHA256 a28b66be40ff87fcf364d9c3d1f9db25167ef24086927ccb1c57add4426be098
MD5 e5ba6fdf99c4457f911ab2ea7cb38c76
BLAKE2b-256 7ad3a3772e063e965dd43e5b5cc5bf4c21368cfdd026b54d2d70ce2ab0676eac

See more details on using hashes here.

File details

Details for the file thumbor_dash-0.0.20-py3-none-any.whl.

File metadata

File hashes

Hashes for thumbor_dash-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 9feed193a0f84fcbeda50a750ae4115fd2913f2573a7fc4ec0fe56bcac4b0491
MD5 0b0ab9ac5a03d1a7fbbf44d49d5335d6
BLAKE2b-256 bc2c5e395e610bfb8d4f844765f4bedbcaa6ce50d5d1ae8acb90dc8f3e357f75

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page