Class: Contents

contents.Contents

A class to handle requests to /api/contents

Implements

Constructors

constructor

new Contents()

Properties

_checkpoints

Private _checkpoints: any

Defined in

packages/contents/lib/contents.d.ts:213


_counters

Private _counters: any

Defined in

packages/contents/lib/contents.d.ts:212


_fileChanged

Private _fileChanged: any

Defined in

packages/contents/lib/contents.d.ts:210


_incrementCounter

Private _incrementCounter: any

Increment the counter for a given file type. Used to avoid collisions when creating new untitled files.

param The file type to increment the counter for.

Defined in

packages/contents/lib/contents.d.ts:208


_isDisposed

Private _isDisposed: any

Defined in

packages/contents/lib/contents.d.ts:209


_serverContents

Private _serverContents: any

Defined in

packages/contents/lib/contents.d.ts:64


_storage

Private _storage: any

Defined in

packages/contents/lib/contents.d.ts:211

Accessors

fileChanged

get fileChanged(): ISignal<IManager, IChangedArgs>

A signal emitted when the file has changed.

Returns

ISignal<IManager, IChangedArgs>

Defined in

packages/contents/lib/contents.d.ts:12


isDisposed

get isDisposed(): boolean

Test whether the manager has been disposed.

Returns

boolean

Defined in

packages/contents/lib/contents.d.ts:16


serverSettings

get serverSettings(): ISettings

Return the server settings.

Returns

ISettings

Defined in

packages/contents/lib/contents.d.ts:20

Methods

addDrive

addDrive(drive): void

Add an IDrive to the manager.

Parameters

Name

Type

drive

IDrive

Returns

void

Implementation of

IContents.addDrive

Defined in

packages/contents/lib/contents.d.ts:143


copy

copy(path, toDir): Promise<IModel>

Copy a file into a given directory.

Parameters

Name

Type

Description

path

string

The original file path.

toDir

string

The destination directory path.

Returns

Promise<IModel>

A promise which resolves with the new contents model when the file is copied.

Notes

The server will select the name of the copied file.

Implementation of

IContents.copy

Defined in

packages/contents/lib/contents.d.ts:45


createCheckpoint

createCheckpoint(path): Promise<ICheckpointModel>

Create a checkpoint for a file.

Parameters

Name

Type

Description

path

string

The path of the file.

Returns

Promise<ICheckpointModel>

A promise which resolves with the new checkpoint model when the checkpoint is created.

Implementation of

IContents.createCheckpoint

Defined in

packages/contents/lib/contents.d.ts:112


delete

delete(path): Promise<void>

Delete a file.

Parameters

Name

Type

Description

path

string

The path to the file.

Returns

Promise<void>

Implementation of

IContents.delete

Defined in

packages/contents/lib/contents.d.ts:103


deleteCheckpoint

deleteCheckpoint(path, checkpointID): Promise<void>

Delete a checkpoint for a file.

Parameters

Name

Type

Description

path

string

The path of the file.

checkpointID

string

The id of the checkpoint to delete.

Returns

Promise<void>

A promise which resolves when the checkpoint is deleted.

Implementation of

IContents.deleteCheckpoint

Defined in

packages/contents/lib/contents.d.ts:139


dispose

dispose(): void

Dispose of the resources held by the manager.

Returns

void

Implementation of

IContents.dispose

Defined in

packages/contents/lib/contents.d.ts:24


driveName

driveName(path): string

Given a path of the form drive:local/portion/of/it.txt get the name of the drive. If the path is missing a drive portion, returns an empty string.

Parameters

Name

Type

path

string

Returns

string

The drive name for the path, or the empty string.

Implementation of

IContents.driveName

Defined in

packages/contents/lib/contents.d.ts:184


get

get(path, options?): Promise<IModel>

Get a file or directory.

Parameters

Name

Type

path

string

options?

IFetchOptions

Returns

Promise<IModel>

A promise which resolves with the file content.

Implementation of

IContents.get

Defined in

packages/contents/lib/contents.d.ts:54


getDownloadUrl

getDownloadUrl(path): Promise<string>

Get an encoded download url given a file path.

Parameters

Name

Type

Description

path

string

An absolute POSIX file path on the server. #### Notes It is expected that the path contains no relative paths. The returned URL may include a query parameter.

Returns

Promise<string>

Implementation of

IContents.getDownloadUrl

Defined in

packages/contents/lib/contents.d.ts:201


getFolder

getFolder(path): Promise<IModel>

retrieve the contents for this path from the union of local storage and api/contents/{path}/all.json.

Parameters

Name

Type

Description

path

string

The contents path to retrieve

Returns

Promise<IModel>

A promise which resolves with a Map of contents, keyed by local file name

Defined in

packages/contents/lib/contents.d.ts:63


getModelDBFactory

getModelDBFactory(path): null | IFactory

Given a path, get a ModelDB.IFactory from the relevant backend. Returns null if the backend does not provide one.

Parameters

Name

Type

path

string

Returns

null | IFactory

Implementation of

IContents.getModelDBFactory

Defined in

packages/contents/lib/contents.d.ts:190


getServerContents

getServerContents(path, options?): Promise<null | IModel>

Attempt to recover the model from {:path}/__all__.json file, fall back to deriving the model (including content) off the file in /files/. Otherwise return null.

Parameters

Name

Type

path

string

options?

IFetchOptions

Returns

Promise<null | IModel>

Defined in

packages/contents/lib/contents.d.ts:79


getServerDirectory

getServerDirectory(path): Promise<Map<string, IModel>>

retrieve the contents for this path from __index__.json in the appropriate folder.

Parameters

Name

Type

path

string

Returns

Promise<Map<string, IModel>>

A promise which resolves with a Map of contents, keyed by local file name

Defined in

packages/contents/lib/contents.d.ts:73


listCheckpoints

listCheckpoints(path): Promise<ICheckpointModel[]>

List available checkpoints for a file.

Parameters

Name

Type

Description

path

string

The path of the file.

Returns

Promise<ICheckpointModel[]>

A promise which resolves with a list of checkpoint models for the file.

Implementation of

IContents.listCheckpoints

Defined in

packages/contents/lib/contents.d.ts:121


localPath

localPath(path): string

Given a path of the form drive:local/portion/of/it.txt get the local part of it.

Parameters

Name

Type

path

string

Returns

string

The local part of the path.

Implementation of

IContents.localPath

Defined in

packages/contents/lib/contents.d.ts:152


newUntitled

newUntitled(options?): Promise<IModel>

Create a new untitled file or directory in the specified directory path.

Parameters

Name

Type

options?

ICreateOptions

Returns

Promise<IModel>

A promise which resolves with the created file content when the file is created.

Implementation of

IContents.newUntitled

Defined in

packages/contents/lib/contents.d.ts:32


normalize

normalize(path): string

Normalize a global path. Reduces ‘..’ and ‘.’ parts, and removes leading slashes from the local part of the path, while retaining the drive name if it exists.

Parameters

Name

Type

path

string

Returns

string

The normalized path.

Implementation of

IContents.normalize

Defined in

packages/contents/lib/contents.d.ts:162


rename

rename(oldLocalPath, newLocalPath): Promise<IModel>

Rename a file or directory.

Parameters

Name

Type

Description

oldLocalPath

string

The original file path.

newLocalPath

string

The new file path.

Returns

Promise<IModel>

A promise which resolves with the new file content model when the file is renamed.

Implementation of

IContents.rename

Defined in

packages/contents/lib/contents.d.ts:88


resolvePath

resolvePath(root, path): string

Resolve a global path, starting from the root path. Behaves like posix-path.resolve, with 3 differences:

  • will never prepend cwd

  • if root has a drive name, the result is prefixed with “:”

  • before adding drive name, leading slashes are removed

Parameters

Name

Type

root

string

path

string

Returns

string

The normalized path.

Implementation of

IContents.resolvePath

Defined in

packages/contents/lib/contents.d.ts:174


restoreCheckpoint

restoreCheckpoint(path, checkpointID): Promise<void>

Restore a file to a known checkpoint state.

Parameters

Name

Type

Description

path

string

The path of the file.

checkpointID

string

The id of the checkpoint to restore.

Returns

Promise<void>

A promise which resolves when the checkpoint is restored.

Implementation of

IContents.restoreCheckpoint

Defined in

packages/contents/lib/contents.d.ts:130


save

save(path, options?): Promise<IModel>

Save a file.

Parameters

Name

Type

Description

path

string

The desired file path.

options?

Partial<IModel>

Optional overrides to the model.

Returns

Promise<IModel>

A promise which resolves with the file content model when the file is saved.

Implementation of

IContents.save

Defined in

packages/contents/lib/contents.d.ts:97