導入一張照片到系統相簿
-
介面描述
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