cyrillef / forge.commandline-curl

Authorization and file translation demo: Demonstrates Autodesk Forge API authorization and translation process using cURL
MIT License
12 stars 8 forks source link

wish: command to display currently supported file formats #1

Closed jeremytammik closed 9 years ago

jeremytammik commented 9 years ago

something along these lines:

./viewerAPI auth

returns bearer.

a suitable CURL command to return file formats is shown in 'step 4 – upload a file':

https://developer.autodesk.com/api/view-and-data-api/#step-4-upload-a-file

curl  -k --header "Authorization: Bearer tMpDT9fGcWsQVd5BG5XUqpYUBbpR" https://developer.api.autodesk.com/viewingservice/v1/supported

massage the result returned, e.g. like this in Python:

a = {"extensions":["ipt","neu","stla","stl","xlsx","jt","jpg","skp","prt","dwf","xls","png","sldasm","step","dwg","zip","nwc","model","sim","stp","ste","f3d","pdf","iges","idw","dwt","dxf","catproduct","csv","igs","sldprt","cgr","3dm","sab","obj","pptx","cam360","jpeg","bmp","gbxml","exp","ppt","doc","wire","ige","rcp","txt","dae","x_b","3ds","rtf","rvt","g","sim360","iam","asm","dlv3","x_t","pps","session","xas","xpr","docx","catpart","stlb","tiff","nwd","sat","fbx","smb","smt","ifc","dwfx","tif"], ... }

a['extensions'].sort()

for e in a['extensions']: print e,

result:

oops, those are too many, both for viewing and extraction only.

to get the viewing ones, filter them like this:

channel_mappings = a['channelMapping']
keys = channel_mappings.keys()
keys.sort()
for x in keys:
  if channel_mappings[x].startswith('view'):
    print x,

result:

cyrillef commented 9 years ago

there is already a command to call that api ./viewerAPI upload -h

it did not list the result like you do, but it displayed the whole response I added some code to do what you suggested - see scripts/upload

jeremytammik commented 9 years ago

wow, cool, thank you!