I am trying to create and download a 3D model as described in the Autodesk Forge documentation [here][1]. Everything is fine up through the successful completion of the model.
I download the file with this PHP code:
$curl_cmd ="curl -o $photosceneDIR/$photosceneID.obj.zip $download_link";
$json = shell_exec ( $curl_cmd );
$json2 = file_get_contents("$photosceneDIR/$photosceneID.obj.zip");
$zip = new ZipArchive;
$res = $zip->open("$photosceneDIR/$photosceneID.obj.zip");
if ($res === TRUE)
{
$zip->extractTo('$photosceneDIR/$photosceneID.obj');
$zip->close();
} else {
echo "ERROR: could not unzip $photosceneDIR/$photosceneID.obj.zip";
}
Since the automatic zip failed, I looked at the contents of the zip archive and I found it reads as follows:
InvalidRequest
Request specific response headers cannot be used for anonymous GET requests.50AD2DF02048EB4Dxkwj8JkN+KWRbrShcz4pGBixF238CzefL1018/oG+5oAj9v5+W40532yQseoZ+aGev0ig/GhaWI=
What code should I use to retrieve my OBJ file?
Try download the file on the CLI and troubleshoot any errors first, and then put the cURL command into your code. You can use the curl -v
option to tell cURL to dump the headers and contents of the actual request that was sent to help you look into errors.
Without looking at your GET request that was actually sent, I'd suggest to remove User-Agent
and Accept
headers (per the Common Request Headers marked acceptable by AWS) when cURLing a S3 object using URLs with header altering query strings (such as the link to download your photoscene output). You can do so with options like below:
curl -H "Accept:" -H "User-Agent:" -o "path/to/your/saved/file" http://s3.amazonaws.com/...
If not specified otherwise cURL sends GET request with default values for these headers. Given the error message you got that could have been the catch here.