Good people, please help, with this code I am trying to download a * .nwd file, the download happens, but when processing (Translate) it gives an error, I also noticed that SHA1 differs in output when downloading and the file I have. What am I missing?
<?php
require_once( "token.php" );
curl_setopt($curl, CURLOPT_URL, "https://developer.api.autodesk.com/oss/v2/buckets/" . $_REQUEST[ "bucket" ] . "/objects/" . hrtime(1) . "_" . $_FILES[ "file" ][ "name" ]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
$post = array(
"file" => new CurlFile( $_FILES[ "file" ][ "tmp_name" ] )
);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$headers = array();
$headers[] = "Authorization: Bearer " . json_decode( $response )->access_token;
$headers[] = "Content-Length: ". $_FILES["file"]["size"];
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec( $curl );
curl_close( $curl );
echo $response;
?>
token.php for authorization
<?php
$client = "";
$secret = "";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://developer.api.autodesk.com/authentication/v1/authenticate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=client_credentials&client_id=".$clien."&client_secret=".$secret."&scope=data%3Aread%20data%3Awrite%20data%3Acreate%20bucket%3Aread%20bucket%3Acreate",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/x-www-form-urlencoded",
"Cookie: PF=NBbXr77IMxHIVlUWgWsny9"
),
));
$response = curl_exec($curl);
?>