Questions about extract.autodesk.io - taking a file path instead of choosing with the file chooser

112 views Asked by At

I'm trying to modify the project so I could plug in a file path or a file as a variable instead of the user choosing the model file. So I'm looking for where the actual upload happens.

In submitProject(): https://github.com/cyrillef/extract.autodesk.io/blob/master/www/js/app.js#L129

I see that it just sends (with an ajax request) an object that holds the file name and unique identifier but not the actual binary file.

In here: https://github.com/cyrillef/extract.autodesk.io/blob/master/www/js/upload-flow.js#L34 there's r.upload(), is this the actual upload of the model?

Does it start to upload the file right as you press ok in the file chooser?

Is there a way to give it a file path to upload instead of uploading with the form and file chooser?

2

There are 2 answers

0
Zhong Wu On BEST ANSWER

The author of this sample should be on Christmas vacation, I just downloaded and setup the extractor sample on my machine, with a little debug into the code, let me try to answer as much as I can.

In general, I think some of your understanding is correct, but let me explain a little more:

For a local file to be uploaded and translated, there are actually 2 steps of actual “upload”.

As you mentioned, when you press ok in the file chooser, yes, the file will be first uploaded to the "extractor" server as you noticed by some methods like r.upload(), it’s actually using a JavaScript library call “flow.js", which provides multiple simultaneous, stable, fault-tolerant and resumable/restartable file uploads via the HTML5 File API. I am not expert on this, but you can check that module about how to use it to upload a file.

By now, your file is uploaded from client to the "extractor" server, but if you want to translate the file to "svf", the file is required to be uploaded to Autodesk Server(OSS), that is done by clicking “submit my project” buton, when you click this button, as you mentioned, from client, it will call the method submitProject() in https://github.com/cyrillef/extract.autodesk.io/blob/master/www/js/app.js, this method will send a post request of “/api/projects” to the "extractor" server, if you check the code at server side https://github.com/cyrillef/extract.autodesk.io/blob/master/server/projects.js , you can see the extractor server actually upload the file to Autodesk OSS, and then triggers the translation service.

0
cyrille On

This feature (passing a URL string vs a file binary) is already implemented. You can use the uri: edit box and paste your file URL there. It supports http(s) or S3 uri with access token. The physical upload happens in this file, whereas the SubmitProject() code sends only information as JSON. The JSON object only contains a reference to the file which was uploaded using flow.js. But would contain the uri string if you had choose that method.