LoopBack Storage Service

Class: StorageService(options)

Storage service constructor. Properties of options object depend on the storage service provider.

Arguments
Name Type Description
options Object

Options to create a provider; see below.

options
Name Type Description
provider String

Storage service provider. Must be one of:

  • 'filesystem' - local file system.
  • 'amazon'
  • 'rackspace'
  • 'azure'
  • 'openstack'

Other supported values depend on the provider. See the documentation for more information.

Class: StorageService Instance Methods

storageService.createContainer(options, cb)

Create a new storage service container.

Arguments
Name Type Description
options Object

Options to create a container. Option properties depend on the provider.

cb Function

Callback function

options
Name Type Description
name String

Container name

Callback
Name Type Description
err Object or String

Error string or object

container Object

Container metadata object

storageService.destroyContainer(container, callback)

Destroy an existing storage service container.

Arguments
Name Type Description
container String

Container name.

callback Function

Callback function.

Callback
Name Type Description
err Object or String

Error string or object

storageService.download(container, file, res, cb)

Download middleware

Arguments
Name Type Description
container String

Container name

file String

File name

res Response

HTTP response

cb Function

Callback function

storageService.downloadStream(container, file, options, callback)

Get the stream for downloading.

Arguments
Name Type Description
container String

Container name.

file String

File name.

options Object

Options for downloading

callback Function

Callback function

Callback
Name Type Description
err String or Object

Error string or object

Returns
Name Type Description
result Stream

Stream for downloading

storageService.getContainer(container, callback)

Look up a container metadata object by name.

Arguments
Name Type Description
container String

Container name.

callback Function

Callback function.

Callback
Name Type Description
err Object or String

Error string or object

container Object

Container metadata object

storageService.getContainers(callback)

List all storage service containers.

Arguments
Name Type Description
callback Function

Callback function

Callback
Name Type Description
err Object or String

Error string or object

containers Array.<Object>

An array of container metadata objects

storageService.getFile(container, file, cb)

Look up the metadata object for a file by name

Arguments
Name Type Description
container String

Container name

file String

File name

cb Function

Callback function

Callback
Name Type Description
err Object or String

Error string or object

file Object

File metadata object

storageService.getFiles(container, [options], cb)

List all files within the given container.

Arguments
Name Type Description
container String

Container name.

[options] Object

Options for download

cb Function

Callback function

Callback
Name Type Description
err Object or String

Error string or object

files Array.<Object>

An array of file metadata objects

storageService.removeFile(container, file, cb)

Remove an existing file

Arguments
Name Type Description
container String

Container name

file String

File name

cb Function

Callback function

Callback
Name Type Description
err Object or String

Error string or object

storageService.upload(req, res, cb)

Upload middleware for the HTTP request/response

Arguments
Name Type Description
req Request

Request object

res Response

Response object

cb Function

Callback function

storageService.uploadStream(container, file, [options], Callback)

Get the stream for uploading

Arguments
Name Type Description
container String

Container name

file String

File name

[options] Object

Options for uploading

Callback callback

function

Callback
Name Type Description
err String or Object

Error string or object

Returns
Name Type Description
result Stream

Stream for uploading

storageService.upload(provider, req, res, container, cb)

Handle multipart/form-data upload to the storage service

Arguments
Name Type Description
provider Object

The storage service provider

req Request

The HTTP request

res Response

The HTTP response

container String

The container name

cb Function

Callback function

storageService.download(provider, req, res, container, file, cb)

Handle download from a container/file.

Arguments
Name Type Description
provider Object

The storage service provider

req Request

The HTTP request

res Response

The HTTP response

container String

The container name

file String

The file name

cb Function

Callback function.