How to store external files
Using the ShapeDiver import components, it is possible to import files in our servers and use them in Grasshopper definitions that are uploaded on ShapeDiver. Allowed file types include multiple geometry formats, common image formats, as well as text, json, xml and csv files.
There are a few things to know when storing files for using in ShapeDiver, most of all how to set the MIME type of the files.
What is a MIME type?
A MIME type is a meta-description of files stored on web servers that are meant to help applications that will download and consume those files, in particular other servers or web browsers. ShapeDiver uses the MIME type to interpret and read the imported files correctly.
Several file types that can be stored on ShapeDiver (such as geometry types OBJ and DXF) are not very common files for web applications, which means that whichever service you are using to store those files might use the wrong type.
Why not use the file extension?
Well, we can. And we do, to some extent (see next paragraph). But file extensions are not as reliable, and some file types (for example, text files) can be stored using many different extensions, which can't test exhaustively. Read below how ShapeDiver interprets imported files.
How ShapeDiver imports files
1. MIME type checking
If the MIME type of the file is defined correctly, and if this type is supported by ShapeDiver, the import will proceed and skip the next steps. This is true for almost all the supported file types.
One notable exception concerns text files. The problem is that by default, when a server doesn't know a certain file type, it often stores it with one of those three types:
application/binary. In particular, this means that the text/plain MIME type can't really be trusted to represent the content of the file. Therefore, if the text/plain format is set, the Shapediver plugin will treat as if the MIME type didn't exist, and proceed to the next step.
2. File extension checking
This second checking step only happens of the file didn't contain information about the MIME type, or the MIME type was set to
In that case, the plugin will try to determine the format by reading the extension of the file. The following extensions will be sucessfully detected:
.svg, .jpg, .jpeg, .png, .bmp, .gif, .tiff, .bin, .dwg, .dxf, .obj, .mtl, .txt, .csv
In practice, this means that if your are storing your files with one of those extensions, the MIME type will not necessarily need to be configured.
Another consequence is that all text files need to be stored using the .txt extension (with the exception of csv files). We will start checking other common file types in the future.
How can I define the MIME type of online stored files?
Unfortunately, this is not always possible and depends on the storage method. For that reason, we recommend using storage services which allow to define the MIME type manually. Cloud computing services such as Amazon Web Services or Microsoft Azure offer storage options with this feature. We detail in the next section how to store files configure their MIME type using Amazon S3 buckets.
If the files are stored using a known extension, then it is possible to use more standard storage services. However, not all of them are guaranteed to be compatible with the import components. At the moment, Dropbox is compatible. In the last paragraph, we explain how to use Dropbox links with ShapeDiver.
Using Amazon S3 buckets
After uploading files to Amazon S3, make sure they are public (Overview tab - > Make Public button) and go to the Properties tab -> Metadata card. Select the Content-Type option, click on Edit and fill the Value field with the appropriate MIME type of your file.
Uploading and storing files with Dropbox is easy, therefore it is an attractive solution to use with ShapeDiver. There is only one detail to take care of: when Dropbox generates download links, they are often in one of the following two forms:
Those links actually link to a Dropbox page with a Download button, but they are not direct download links to the stored files. To create a proper link, replace or add the query parameter like this: