Skip to content

Image Downloads

Using Headers

The add_documents, update_documents, and search endpoints all download images (provided the input includes a downloadable image URL). In certain instances, headers will be needed to authenticate these URLs before image download.

In cases like these, use the image_download_headers parameter to specify these headers in A JSON-serialised, URL encoded dictionary. See example usage below:

Image download headers usage in add_documents

import marqo
mq = marqo.Client(url='http://localhost:8882')

mq.index("my-first-index").add_documents(
    [{
        "Title": "Treatise on the future of hippos",
        "img": "https://non-public-images.com/cat/3189471/preview.png"
    }],
    image_download_headers={'Authorization': 'iu498nc1n89v48v6w4f'}
)

Image download headers usage in update_documents

mq.index("my-first-index").update_documents(
    [{
        "Title": "Treatise on the future of hippos",
        "img": "https://non-public-images.com/cat/3189471/preview.png"
    }],
    image_download_headers={'Authorization': 'iu498nc1n89v48v6w4f'}
)
mq.index("my-first-index").search(
    "https://non-public-images.com/cat/3189471/preview.png",
    image_download_headers={
        'Authorization': 'iu498nc1n89v48v6w4f'}
)