0

我无法在 Autodesk 的Forge API中将图像文件添加到照片场景中。

我尝试过使用两种方法,但都失败了,尽管每种方法都有不同的错误消息:

使用 URL指定文件:

json=`curl -v -s $FORGE_URL/photo-to-3d/v1/file \
        -H "Authorization: Bearer $forge_access_token" \
        -d "photosceneid=$photosceneid" \
        -d 'type=image' \
        -d "file[1]=http://cloud1.tri-di.com/scans/VG1.3/20200617191821/img01-cam00-USB+2.0+Camera+26.jpg" 

上面的代码会产生以下错误:

{
  "msg": "An error occurred while trying to copy the file",
  "code": "34"
}

使用本地文件名指定文件:

当我 cd 到包含图像文件的本地目录时,我可以像这样指定 files[1]:

    json=`curl -v -s $FORGE_URL/photo-to-3d/v1/file \
    -H "Authorization: Bearer $forge_access_token" \
    -d "photosceneid=$photosceneid" \
    -d 'type=image' \
    -d "file[1]=img01-cam00-USB+2.0+Camera+26.jpg" 
`

然后我收到以下错误消息:

{
  "msg": "Specified image protocol is invalid",
  "code": "18"
}

调用curl -v会提供以下调试信息。

  Trying 34.197.193.140...
* Connected to developer.api.autodesk.com (34.197.193.140) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 598 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
*    server certificate verification OK
*    server certificate status verification SKIPPED
*    common name: developer.api.autodesk.com (matched)
*    server certificate expiration date OK
*    server certificate activation date OK
*    certificate public key: RSA
*    certificate version: #3
*    subject: businessCategory=Private Organization,jurisdictionOfIncorporationCountryName=US,jurisdictionOfIncorporationStateOrProvinceName=Delaware,serialNumber=2401504,C=US,ST=California,L=San Rafael,O=Autodesk\, Inc.,OU=MCP-ASRD-CP,CN=developer.api.autodesk.com
*    start date: Mon, 24 Feb 2020 00:00:00 GMT
*    expire date: Mon, 22 Mar 2021 12:00:00 GMT
*    issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert SHA2 Extended Validation Server CA
*    compression: NULL
* ALPN, server did not agree to a protocol
> POST /photo-to-3d/v1/file HTTP/1.1
> Host: developer.api.autodesk.com
> User-Agent: curl/7.47.0
> Accept: */*
> Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJzY29wZSI6WyJkYXRhOnJlYWQiLCJkYXRhOndyaXRlIl0sImNsaWVudF9pZCI6IkhBcUR0S083VmJ1UmdIMG5MME1GSjBCMDJFbEJFSzNsIiwiYXVkIjoiaHR0cHM6Ly9hdXRvZGVzay5jb20vYXVkL2p3dGV4cDYwIiwianRpIjoid2lwVWw2dGNCdndPdnYzT29jVWV0anFQNFRMOXBiZVdGZm80NGtGUWhDYVpudGJ5OXZCcFdNTWpjYU1IeDRhTSIsImV4cCI6MTU5MjQ1MDM5MH0.j2_DaSyZGhs87MqtugollT1D-1Tv4-zkBDaQwjKT8yg
> Content-Length: 142
> Content-Type: application/x-www-form-urlencoded
> 
} [142 bytes data]
* upload completely sent off: 142 out of 142 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Thu, 18 Jun 2020 02:59:26 GMT
< Server: Apache/2.4.6 (CentOS)
< X-Powered-By: PHP/7.0.33
< Content-Length: 126
< Connection: keep-alive
< 

有没有其他人有类似的问题?你是怎么解决的?

4

1 回答 1

0

与其将所有信息作为数据(-d 标志)发送,不如将其作为表单内容(-F 标志)发送:

curl --location --request POST 'https://developer.api.autodesk.com/photo-to- 3d/v1/file' \
-H "Authorization: Bearer $TOKEN" \
-F "photosceneid=$PHOTOSCENE" \
-F "type=image" \
-F "file[0]=http://cloud1.tri-di.com/scans/VG1.3/20200617191821/img01-cam00-USB+2.0+Camera+26.jpg"

我将向工程团队报告以更改文档以反映这种方法。

于 2020-06-18T19:14:12.543 回答