我想在我的php应用程序中使用Autodesk Forge Viewer api来查看ifc文件,所以我使用了forge-php-client sdk。一切正常,但翻译工作无法完成,并且出现此错误:[404]连接到API(https://developer.api.autodesk.com/modelderivative/v2/designdata/job 这里的代码:
/step1
Configuration::getDefaultConfiguration()
->setClientId('xxxxxxxxxxxxxxxxxxxxxx')
->setClientSecret('xxxxxxxxxxxxxxxxxx');
$twoLeggedAuth = new TwoLeggedAuth();
$twoLeggedAuth->setScopes( [ 'bucket:create' ] );
$twoLeggedAuth->fetchToken();
$tokenInfo = [
'accessToken' => $twoLeggedAuth->getAccessToken(),
'expiry' => time() + $twoLeggedAuth->getExpiresIn(),
];
//step2
$twoLeggedAuth->setScopes( [ 'bucket:create' ] );
$twoLeggedAuth->fetchToken();
$apiInstance = new BucketsApi( $twoLeggedAuth );
$bucket_info = array(
'bucket_key' => 'nebnibim5'.time(),
'policy_key' => 'transient'
);
$post_buckets = new PostBucketsPayload( $bucket_info );
$result = $apiInstance->createBucket( $post_buckets, null );
$twoLeggedAuth = new TwoLeggedAuth();
$twoLeggedAuth->setScopes( [ 'data:write' ] );
$twoLeggedAuth->fetchToken();
$apiInstance = new ObjectsApi( $twoLeggedAuth );
$bucket_key = $bucket_info['bucket_key'];
$filename = 'C:\wamp\www\nebnibim\storage\app\bibliothequeObjets\user69\13111006_IFCR2_Geo_Openings_1.ifc ';
$body = $filename;
$file = new SplFileObject( $body );
$content_length = $file->getSize();
$object_name = $file->getFilename();
//try {
$result2 = $apiInstance->uploadObject( $bucket_key, $object_name, $content_length, $body, null, null );
//step4
$urn = 'urn:adsk.objects:os.object:nebnibim51548575979/13111006_IFCR2_Geo_Openings_1.ifc';
$base64Urn = rtrim( strtr( base64_encode( $urn ), '+/', '-_' ), '=' );
$twoLeggedAuth->setScopes( [ 'data:read', 'data:write' ] );
$twoLeggedAuth->fetchToken();
$apiInstance2 = new DerivativesApi( $twoLeggedAuth );
$jobInput = array(
'urn' => 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bmVibmliaW01MTU0ODU3NTk3OS8xMzExMTAwNl9JRkNSMl9HZW9fT3BlbmluZ3NfMS5pZmM'
);
$jobPayloadInput = new JobPayloadInput( $jobInput );
$jobOutputItem = array(
'type' => 'svf',
'views' => array( '2d', '3d' )
);
$jobPayloadItem = new JobPayloadItem( $jobOutputItem );
$jobOutput = [
'formats' => array( $jobPayloadItem )
];
$jobPayloadOutput = new JobPayloadOutput( $jobOutput );
$job = new JobPayload();
$job->setInput( $jobPayloadInput );
$job->setOutput( $jobPayloadOutput );
$x_ads_force = false;
$resultat= $apiInstance2->translate( $job,$x_ads_force );
答案 0 :(得分:0)
好像您仍在上传到以系统时间命名的存储桶,只是调用硬编码骨灰盒上的作业,以指向之前已上传到另一个存储桶的对象-这总是会导致404错误,因为骨灰盒不正确。
按照此处的code sample和docs来获取现有存储桶内容的列表,在查询时验证存储桶中对象确实存在,并取回保证的objectId是最新且正确的,然后从那里去。
由于创建的存储桶为transient
,因此您需要在24小时后再次上传文件。有关更多信息,请参见here-这应该是我们现在看到的错误的原因。