BIM 360 API versions:batch-get request doesn't return any attribute for file in "Upload Zone" folder - autodesk-forge

Using the request curl -X POST -v "https://developer.api.autodesk.com/bim360/docs/v1/projects/'.$id_project.'/versions:batch-get" ....
we are able to get custom attributes for files located in the Plans folder but if the files are located in the "UploadZone" folder the request show no custom attribute (see image bellow)
We try using exactly the same PDF file in Plans and UploadZone folder, putting same custom attributes on both documents. Same proble, API retrieve custom attribute for the file in Plans folder but not for the one in UploadZone.

Related

Is it possible to retrieve a list of files in a JSON format from a URL that lists the contents of a folder

I have a NFS location that is not managed by me and it's contents can be accessed by browsing to it, i.d. the server is serving up the folder as a HTML page.
something like https://ftp.mozilla.org/pub/firefox/releases/52.0/
Is it possible to get the list of files in a JSON format response directly in the request response? Without changing anything on the NFS server and without having to write code to parse the HTML?
e.g., Maybe I can send the request to the URL with different headers.
To clarify:
When you access the address with a browser, curl or wget, you get a HTML page.
My motivation is that I don't want to mount the NFS location. I want to access the files by downloading them from the URL.
I don't know the type of server that is holding the shared folder.
Thanks.
In short, the answer is NO.
Not without tweaking the settings on the webserver that is serving the folder contents.
Here are some examples of how to tweak Apache to serve JSON formatted files listing for the folder.
Apache directory listing as JSON using PHP
Apache directory listing as json
Apache External Module mod_jsonindex - May not be the recommended way
http://1h.com/opensource/mod_jsonindex.html

Create download link for static asset file

I would like to put a download link on my website so the users can download the file template.csv. The file is static and is located at the root of my /grails-app/assets folder.
Inside my page.gsp, I have tried 2 methods do so, to no avail :
Download the template
this results in a template.csv file being downloaded, but the content is the html code of page.gsp rather than the original content of the file I uploaded in my assets.
Download the template
the generated html file has a link to localhost:8080/mysite/assets/template.csv but clicking it prompts an error message : Failed - no file.
What is the correct way to do what I want to achieve ? Is there an issue with extra permissions I would need to add to allow the download of my file ?
Our webapp relies on a rather old technological stack :
Grails 2.3.4
Plugin asset-pipeline-2.2.5
I have had some troubles with downloading files straight with a -tag.
To overcome this, I use Controller method to return the file and place the downloadable files in their own folder under web-app/:
class MyController {
#Autowired()
AssetResourceLocator assetResourceLocator
def downloadExcelTemplate () {
String fileName = "MyExcelFile.xlsx"
/* Note: these files are found in /web-app/downloadable directory */
Resource resource = assetResourceLocator.findResourceForURI("/downloadable/$fileName")
response.setHeader "Content-disposition", "attachment; filename=${resource.filename}"
response.contentType = 'application/vnd.ms-excel'
response.outputStream << resource.inputStream.bytes
}
}
And just use regular a-tag to to link to this controller method.
This way you also gain more control over file downloads.

show linked files in autodesk forge viewer

i am trying to make auto-desk forge viewer.
using this link Forge & ASP.NET: from zero to hero in 30 minutes
and it works fine with single revit file.
now i want to view revit document that has linked document and i found this post How to Set References with Revit Files for View and Data API
but i think it is an old version of api.
so i don't know how to apply these steps in the viewer code.
any help
A zipped file which is contained the host RVT file and corresponding linked files can help you archive this goal. After uploading this ZIP file to the Forge DM, you have to make sure that ‘compressedUrn: true’ and ‘rootFilename: {your host RVT filename with the sub filename .rvt}’ your input field of the job configuration body while submitting your translation job. Please refer here for the details: https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/
Some more info:
If you do not want to manage the reference, while simply count on Forge detects the reference automatically, the choice is what Eason mentioned: package all files in an zip, upload, and ask Forge Post Job service to translate the zip. You only need to specify the root file.
https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/
This blog tells more:
https://forge.autodesk.com/cloud_and_mobile/2016/07/translate-referenced-files-by-derivative-api.html
If you want to manage the reference, e.g. in one time, you have uploaded all files of one version or only a few files of the package. While after some time, some files need to be updated, or are not referred anymore, but it is unnecessary to upload all related files again (as in #1, upload zip again).
In such scenario, the choice is, firstly, set reference manually by another Forge service (Set Reference):
https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-references-POST/
next, ask POST Job service to translate:
https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/
As of 1/2020 Autodesk has said that they do not support reference endpoint when exporting to SVG so zip file is the only supported method currenty.

Uploading a file to the plans folder in BIM360Docs

I'm new to using the data management API to gain access to BIM360Docs, I've successfully downloaded a file from any folder and I can upload to the project files folder, however the issue lies with uploading to the plans folder, all the API calls seem happy and appears to work, but when I check the actual BIM360Docs website it's not there, when I use the API call to display a folders contents it is there, so it appears to be uploading correctly yet isn't visible for some reason?
Here it is being uploaded successfully:
Here it is being visible using the get folder contents API call but not in docs:
So it is there and I can download it and everything is hunky dory I just can't see it on the website.
PS I'm using the step by step guide on the forge site (I'm unable to link as I don't have enough rep).
Can you tell me to what folder location are you uploading? I'm thinking maybe you are not posting the file to the right location, and that is why you can download it only. In that sense you are correctly creating the storage location, the problem is you are probably uploading your file to the wrong folder. Something I can suggest is the following, get a list of all the available folder within the root folder.
// Get Folder
curl -X GET -H "Authorization: Bearer YOURTOKEN" "https://developer.api.autodesk.com/data/v1/projects/BIM360ACCOUNTID/folders/urn%3Aadsk.wipprod%3Afs.folder%3AYOURROOTFOLDER/contents"
This will give you back a response JSON of all the folder within your Doc Project. Find the ID of the Plans Folder and continue with the following steps using that folder identifier.
//Step 3: Create a storage location
//Step 4: Upload a file to the storage location
//Step 5: Create the first version of the uploaded file
If everything goes correctly you should be able to see your plans in that location now. Please let me know how everything goes with this. Also check that you have the right Scopes setup in your token that the following ones are included scope= account:read account:write
Also that you have the right permissions within your Docs project to upload.

Convert .html files to .mhtml using Java API

I have some generated .html reports in a folder and want to convert multiple .html, .css, .js and image files into one report.mhtml file so that single file can be accessed as a web service.
Is there any Java API to convert the folder of .html files to a single .mhtml file?
I was investigating the reverse (unpacking an MHTML/EML to files) and while there didn't seem to be a simple Java-based utility to do this, I found the Apache Mime4J libraries to be very useful (and easier than JavaMail).
You can find the code I shared here: How to read or parse MHTML (.mht) files in java
For your case, to build an MHTML, if you can't find anything simpler, approach could be:
Create a Message object which has a Multipart body.
Read all files in a folder using Streams, append these as BodyParts of the Multipart with their mime-type (Mime4j includes a Base64 stream encoder/decoder).
Ensure the references in the html page point to the necessary body parts (may be able to embed their original filename as reference?).
Write the Message object to mht file or a response stream.