0
votes

I've been following this viewer walkthrough tutorial (node.js), for uploading and showing a file in the forge viewer.

I've been using angular to recreate the example, except instead of a user uploading a file, the file is hardcoded into the app from my assets folder for testing purposes.

The issue comes to when i try and translate the revit file into svf.

I know there isn't an issue with the revit file as i have used models.autodesk.io to check if all is good.

I can successfully create a bucket and post a job, but when calling the translation status to check if translation is completed, i receive this:

{
    "type": "manifest",
    "hasThumbnail": "false",
    "status": "failed",
    "progress": "complete",
    "region": "US",
    "urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6OTA0ZmZmYmMtODI1Ni00OWY2LWI3YzYtNDI3MmM1ZDlmNDljL2RyYXBlLnJ2dA",
    "version": "1.0",
    "derivatives": [
        {
            "name": "drape.rvt",
            "hasThumbnail": "false",
            "status": "failed",
            "progress": "complete",
            "messages": [
                {
                    "type": "error",
                    "code": "Revit-UnsupportedFileType",
                    "message": "<message>The file is not a Revit file or is not a supported version.</message>"
                },
                {
                    "type": "error",
                    "message": "Possibly recoverable warning exit code from extractor: -536870935",
                    "code": "TranslationWorker-RecoverableInternalFailure"
                }
            ],
            "outputType": "svf"
        }
    ]
}

I'm pretty sure my code for translating a project is correct, i think the issue is coming from uploading the file to my bucket.

The body structure for the PUT request must contain the contents of the file.

Here is my code for loading and reading a file using XMLHttpRequest and FileReader

  loadFile(bucketKey, accessToken) {

    const reader: XMLHttpRequest = new XMLHttpRequest();
    reader.open('GET', './assets/drape.rvt', true);
    reader.responseType = 'blob';

    reader.onloadend = (request) => {

        const blob: Blob = reader.response;

        console.log(blob); //returns BlobĀ {size: 372736, type: "text/xml"}

        // Create file from blob
        const modelFile: File = new File([blob], 'drape.rvt');

        this.readFile(bucketKey, accessToken, modelFile);

    };

    reader.send();
  }

  readFile(bucketKey, accessToken, modelFile) {

    const myReader: FileReader = new FileReader();

    myReader.readAsArrayBuffer(modelFile);
    myReader.onloadend = (e) => {

      const arrayBuffer: ArrayBuffer = myReader.result as ArrayBuffer;

      this.fileToBucket(bucketKey, accessToken, arrayBuffer);
    };
  }

And the put request:

  fileToBucket(bucketKey, accessToken, fileContent) {

    const encodedBucketKey = encodeURIComponent(bucketKey);
    const encodedFileName = encodeURIComponent('drape.rvt');
    const uploadURI = `https://developer.api.autodesk.com/oss/v2/buckets/${encodedBucketKey}/objects/${encodedFileName}`;

    const options = {
      headers: new HttpHeaders({
        'Content-Type':  'application/octet-stream',
        Authorization: 'Bearer ' + accessToken
      })
    };

    const body = {
      data: fileContent
    };

    this.http.put(uploadURI, body, options)
    .subscribe(
      success => {

        // URL safe base64 encoding
        const urn = btoa(success.objectId);
        this.translateObject(accessToken, urn);
      }, error => {
        console.log('fileToBucket');
        console.log(error);
      });
  }

I'm assuming that the file content is the issue, here is the equivalent using node.js for the tutorial: PUT request read file.

1

1 Answers

1
votes

You can use a utility web app like https://oss-manager.autodesk.io/ to check if the file you previously uploaded is correct (by downloading it or trying to translate it to SVF through the app's UI) and upload the file using this utility and then try to translate it with your app. It can also be used to delete all the derivatives for a given file in your bucket. That could help narrow down the issue.

It's also possible that the file was not correctly uploaded the first time (at a certain point when you were still testing things) and so the translation failed back then and now it won't try to translate the file again. You can force the translation to take place by adding x-ads-force to the POST Job request with value "true" - see https://forge.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/