Files


Files in Nextspace come in three different forms. They are either Client Files, temporary files, and Tileset files.

Client Files

Client Files are the most common kind of file you will find your Nextspace account. You will be able to upload these yourself and tie them to Entity records as attachments.

Client Files will also be used for the following:

  • Markup media
  • Bookmark thumbnails
  • Branding


Here is how you can upload a Client File to your Nextspace account. This example will account for large files and use a multi-part upload when a size threshold is reached.

Typescript
Javascript
import { ENVIRONMENT, ClientFile } from "bruce-models";

// Setup global defaults.
ENVIRONMENT.PARAMS = {
    ...ENVIRONMENT.PARAMS,
    accountId: "your-account-id",
    sessionId: "your-session-id"
};

// Some file, eg: selected from a file input. Cannot be null.
const file = null;

ClientFile.Upload({
    file: file
}).then((data) => {
    console.log(data);
}).catch((e) => {
    console.error(e);
});

// Here is how you can monitor progress as it uploads.
ClientFile.Upload({
    file: file,
    onProgress: (progress) => {
        // Includes a % value and an "uploaded" boolean.
        console.log(progress);
    }
}).then((data) => {
    console.log(data);
}).catch((e) => {
    console.error(e);
});

// After you've uploaded a file you can access its ID to produce a URL.
const clientFileId = null;
const url = ClientFile.GetUrl({
    fileId: clientFileId
});

Entity attachments

Entity attachments are Client Files that are tied to Entity records.

These attachments are commonly seen in Navigator in the 'Media' and 'Attachments' tabs within the selected Entity panel.


Here is how you can upload an attachment to your Nextspace Entity. It is recommended to keep attachments under 100MB in size.

Typescript
Javascript
import { ENVIRONMENT, EntityAttachment, ClientFile } from "bruce-models";

// Setup global defaults.
ENVIRONMENT.PARAMS = {
    ...ENVIRONMENT.PARAMS,
    accountId: "your-account-id",
    sessionId: "your-session-id"
};

// Some file, eg: selected from a file input. Cannot be null.
const file = null;

EntityAttachment.Upload({
    file: file,
    entityId: "your-entity-id",
    // Replace with "photo" to upload into the Navigator 'media' tab.
    attachmentTypeId: "document"
}).then((data) => {
    console.log(data);

    // After you've uploaded a file you can access its ID to produce a URL.
    const clientFileId = data.attachment["ClientFile.ID"];
    const url = ClientFile.GetUrl({
        fileId: clientFileId
    });
}).catch((e) => {
    console.error(e);
});

Temporary files

Temporary Files are files that are uploaded to Nextspace for a short period of time. They are used for the following:

  • Importing certain files
  • Exporting certain formats


Here is how you can upload a temporary file to your Nextspace account. This example will account for large files and use a multi-part upload when a size threshold is reached.

Typescript
Javascript
import { ENVIRONMENT, ClientFile } from "bruce-models";

// Setup global defaults.
ENVIRONMENT.PARAMS = {
    ...ENVIRONMENT.PARAMS,
    accountId: "your-account-id",
    sessionId: "your-session-id"
};

// Some file, eg: selected from a file input. Cannot be null.
const file = null;

ClientFile.UploadTemp({
    file: file
}).then((data) => {
    console.log(data);
}).catch((e) => {
    console.error(e);
});

// Here is how you can monitor progress as it uploads.
ClientFile.UploadTemp({
    file: file,
    onProgress: (progress) => {
        // Includes a % value and an "uploaded" boolean.
        console.log(progress);
    }
}).then((data) => {
    console.log(data);
}).catch((e) => {
    console.error(e);
});

Tileset files

A Tileset file can be uploaded into a Tileset record to either process the file into streamable graphics, or to directly provide pre-process streamable graphics.

For example a ".las" file can be uploaded into a Tileset record to be processed into a streamable point cloud. Or a ".b3dm" file can be uploaded into a Tileset record to directly provide a streamable 3D model.

Tileset files are typically not tracked as they can come in large quantities and are not typically referenced outside of rendering the Tileset.


Here is how you can upload a Tileset file to your Nextspace account. This example will account for large files and use a multi-part upload when a size threshold is reached.

WARNING: Do not use these functions for 'Static' Tilesets as they're considered legacy and require a different upload process.

Typescript
Javascript
import { ENVIRONMENT, Tileset } from "bruce-models";

// Setup global defaults.
ENVIRONMENT.PARAMS = {
    ...ENVIRONMENT.PARAMS,
    accountId: "your-account-id",
    sessionId: "your-session-id"
};

// Some file, eg: selected from a file input. Cannot be null.
const file = null;

// Upload a source file for processing. Eg: a '.las' file.
Tileset.UploadSrcFile({
    tilesetId: "your-tileset-id",
    file: file
}).then(() => {
    console.log("success!");
}).catch((e) => {
    console.error(e);
});

// Upload a file for direct use. Eg: a '.b3dm' file.
Tileset.UploadFile({
    tilesetId: "your-tileset-id",
    file: file
}).then(() => {
    console.log("success!");
}).catch((e) => {
    console.error(e);
});