Styles

A Style is a custom set of branding that can be applied on a per-folder basis. Currently these support a logo per folder and an optional click-through URL for public visitors. In the future we may extend these to also support colors. If you want to see that, please let us know so we can add your vote to the list.

Show Style

SDK Method

Style.find()

Return Object

Style

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
path
string
Required
Style path.

Example Request

import Style from 'files.com/lib/models/Style';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const style = await Style.find(path);
  // Operate on style
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Update Style

SDK Method

style.update()

Return Object

Style

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Folder Admin permissions.

Method Arguments

ArgumentDescription
file
file
Logo for custom branding. Required when creating a new style. See Attaching Files to API Requests.
logo_click_href
string
URL to open when a public visitor clicks the logo.

Example Request

import Style from 'files.com/lib/models/Style';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the style object by its path.
  const style = await Style.find(path);
  await style.update({
    logo_click_href: "https://www.example.com",
  });
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Delete Style

SDK Method

style.delete()

Return Object

No return value.

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Folder Admin permissions.

Example Request

import Style from 'files.com/lib/models/Style';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the style object by its path.
  const style = await Style.find(path);
  await style.delete();
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

The Style Object

Some of the methods above return a Style object. The attributes of this object are listed below.

AttributeDescription
id
int64
Style ID
path
string
Folder path. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
logo
Image
Logo
logo_click_href
string
URL to open when a public visitor clicks the logo
thumbnail
Image
Logo thumbnail