写真をシステムのアルバムに読み込む
-
インターフェースの説明
POST /image_to_album HTTP/1.1
[画像データ] -
返される可能性のあるレスポンス
{"code":0,"message":"操作成功"}{"code":1,"message":"操作失败"} -
コンピューターからデバイスのアルバムに画像を読み込む例(Python 3.x に対応):
# -*- coding: utf-8 -*-
import http.client
import json
imgf = open('r:/1.png', 'rb') # 画像ファイルのパス
imgdata = imgf.read()
conn = http.client.HTTPConnection("192.168.31.72:46952") # デバイスのアドレスとポート
conn.request("POST", "/image_to_album", imgdata)
response = conn.getresponse()
if response.status == 200:
ret = json.loads(response.read().decode('utf-8')) # UTF-8 として明示的にデコード
print(ret['message'])
else:
print(response.status, response.reason)
print(response.read().decode('utf-8')) # UTF-8 として明示的にデコード
conn.close() -
説明
- PNG、JPG 形式のデータに対応しています