Home Reference Source
public class | source

Asset

Asset

A model representing a file reference in Skygear record.

Static Method Summary

Static Public Methods
public static

fromJSON(attrs: Object): Asset

Constructs a new Asset object from JSON object.

Constructor Summary

Public Constructor
public

constructor(attrs: Object)

Constructs a new Asset object.

Member Summary

Public Members
public

contentType: String

Mime of the file

public

file: File | Blob

File object

public

name: String

Asset name

public

url: String

Url of the file on Skygear server

Method Summary

Public Methods
public

toJSON(): Object

Serializes Asset to a JSON object.

Static Public Methods

public static fromJSON(attrs: Object): Asset source

Constructs a new Asset object from JSON object.

Params:

NameTypeAttributeDescription
attrs Object

the JSON object

attrs.$name String

asset name

attrs.$url String

url of the file on Skygear server

attrs.$content_type String

mime of the file

Return:

Asset

the created Asset object

Public Constructors

public constructor(attrs: Object) source

Constructs a new Asset object. Either file, url or base64 must be provided.

Params:

NameTypeAttributeDescription
attrs Object
attrs.name String

asset name

attrs.file File | Blob | Buffer
  • optional

file or buffer object

attrs.base64 String
  • optional

base64 encoded file content

attrs.contentType String
  • optional

mime of the file

attrs.url String
  • optional

url of the file on Skygear server

Public Members

public contentType: String source

Mime of the file

public file: File | Blob source

File object

public name: String source

Asset name

public url: String source

Url of the file on Skygear server

Public Methods

public toJSON(): Object source

Serializes Asset to a JSON object.

Return:

Object

the JSON object