我正在使用 python 将一些 .jpg 图像上传到我创建的照片场景,但我不断收到这个错误。
{'Usage': '0.48637413978577', 'Resource': '/file', 'Error': {'code': '19', 'msg': "Specified Photoscene ID doesn't exist in the database"}}
这是我的代码,photoscene 创建效果很好,我得到了 photoscene id 并将其复制为字符串以将其存储为“sceneId”
formData = {'Content-Type': 'multipart/form-data', 'Authorization': 'Bearer eyXXXX'}
sceneId = "l5w----etc-etc------qQ"
# This bit is so I can use tkinter to choose my images
application_window = tk.Tk()
application_window.withdraw()
answer = filedialog.askopenfilenames(parent=application_window,
initialdir=os.getcwd(),
title="Please select one or more files:",
filetypes=[("Image files", ".jpg .jpeg")])
if answer != "":
files = {
"photosceneid":(None, sceneId),
"type":(None, "image")
}
n=-1
for a in answer:
n = n+1
a = a.replace("/", "//")
files["file[{x}]".format(x=n)] = (a, open(a,"rb"))
# This bit adds keys and values to the dictionary as "file[0]": ("path//to//image//", open("path//to//image//","rb"))
r = requests.post("https://developer.api.autodesk.com/photo-to-3d/v1/file",headers=formData,files=files).json()
print(r)
我正在关注官方api 参考中的片段
curl -v 'https://developer.api.autodesk.com/photo-to-3d/v1/file' \
-X 'POST' \
-H 'Authorization: Bearer eyjhbGCIOIjIuzI1NiISimtpZCI6...' \
-F "photosceneid=hcYJcrnHUsNSPII9glhVe8lRF6lFXs4NHzGqJ3zdWMU" \
-F "type=image" \
-F "file[0]=@c:/sample_data/_MG_9026.jpg" \
-F "file[1]=@c:/sample_data/_MG_9027.jpg"
感谢您的阅读和帮助!
繁花如伊
不负相思意
相关分类