nectar.imageuploader module
- class nectar.imageuploader.ImageUploader(base_url: str = 'https://images.hive.blog', challenge: str = 'ImageSigningChallenge', blockchain_instance: Any | None = None)
Bases:
object- upload(image: str | bytes | BytesIO, account: str | Account, image_name: str | None = None) Dict[str, Any]
Upload an image to the configured image service, signing the upload with the account’s posting key.
The function accepts a filesystem path (str), raw bytes, or an io.BytesIO for the image. It locates the account’s posting private key from the blockchain wallet, signs the image data together with the uploader’s challenge string, and POSTs the image under the key image_name (defaults to “image”) to: <base_url>/<account_name>/<signature_hex>.
- Parameters:
image (str | bytes | io.BytesIO): Path to an image file, raw image bytes, or an in-memory bytes buffer. account (str | Account): Account identifier (must have posting permission); used to select the signing key. image_name (str, optional): Form field name for the uploaded image (defaults to “image”).
- Returns:
dict: Parsed JSON response from the image service.
- Raises:
AssertionError: If the account’s posting permission (and therefore a posting key) cannot be accessed.