Zum Hauptinhalt springen

Foto in die Systemfotos-App importieren

  • Schnittstellenbeschreibung

    POST /image_to_album HTTP/1.1

    [Bilddaten]
  • Mögliche Antworten

    {"code":0,"message":"操作成功"}
    {"code":1,"message":"操作失败"}
  • Beispiel zum Importieren eines Bildes vom Computer in das Gerätealbum (für Python 3.x):

    # -*- coding: utf-8 -*-
    import http.client
    import json

    imgf = open('r:/1.png', 'rb') # Pfad der Bilddatei
    imgdata = imgf.read()

    conn = http.client.HTTPConnection("192.168.31.72:46952") # Adresse und Port des Geräts
    conn.request("POST", "/image_to_album", imgdata)

    response = conn.getresponse()

    if response.status == 200:
    ret = json.loads(response.read().decode('utf-8')) # Explizit als UTF-8 decodieren
    print(ret['message'])
    else:
    print(response.status, response.reason)
    print(response.read().decode('utf-8')) # Explizit als UTF-8 decodieren

    conn.close()
  • Hinweise

    • Unterstützte Datenformate sind PNG und JPG.