Class: StorageService(options)
Storage service constructor. Properties of options object depend on the storage service provider.
Name | Type | Description |
---|---|---|
options |
Object
|
Options to create a provider; see below. |
Name | Type | Description |
---|---|---|
provider |
String
|
Storage service provider. Must be one of:
Other supported values depend on the provider. See the documentation for more information. |
storageService.createContainer(options, cb)
Create a new storage service container.
Name | Type | Description |
---|---|---|
options |
Object
|
Options to create a container. Option properties depend on the provider. |
cb |
Function
|
Callback function |
Name | Type | Description |
---|---|---|
name |
String
|
Container name |
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.
Name | Type | Description |
---|---|---|
container |
String
|
Container name. |
callback |
Function
|
Callback function. |
Name | Type | Description |
---|---|---|
err |
Object or String
|
Error string or object |
storageService.download(container, file, req, res, cb)
Download middleware
Name | Type | Description |
---|---|---|
container |
String
|
Container name |
file |
String
|
File name |
req |
Request
|
HTTP request |
res |
Response
|
HTTP response |
cb |
Function
|
Callback function |
storageService.downloadStream(container, file, options, callback)
Get the stream for downloading.
Name | Type | Description |
---|---|---|
container |
String
|
Container name. |
file |
String
|
File name. |
options |
Object
|
Options for downloading |
callback |
Function
|
Callback function |
Name | Type | Description |
---|---|---|
err |
String or Object
|
Error string or object |
Name | Type | Description |
---|---|---|
result |
Stream
|
Stream for downloading |
storageService.getContainer(container, callback)
Look up a container metadata object by name.
Name | Type | Description |
---|---|---|
container |
String
|
Container name. |
callback |
Function
|
Callback function. |
Name | Type | Description |
---|---|---|
err |
Object or String
|
Error string or object |
container |
Object
|
Container metadata object |
storageService.getContainers(callback)
List all storage service containers.
Name | Type | Description |
---|---|---|
callback |
Function
|
Callback function |
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
Name | Type | Description |
---|---|---|
container |
String
|
Container name |
file |
String
|
File name |
cb |
Function
|
Callback function |
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.
Name | Type | Description |
---|---|---|
container |
String
|
Container name. |
[options] |
Object
|
Options for download |
cb |
Function
|
Callback function |
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
Name | Type | Description |
---|---|---|
container |
String
|
Container name |
file |
String
|
File name |
cb |
Function
|
Callback function |
Name | Type | Description |
---|---|---|
err |
Object or String
|
Error string or object |
storageService.upload(req, res, [options], cb)
Upload middleware for the HTTP request/response
Name | Type | Description |
---|---|---|
req |
Request
|
Request object |
res |
Response
|
Response object |
[options] |
Object
|
Options for upload |
cb |
Function
|
Callback function |
storageService.uploadStream(container, file, [options], Callback)
Get the stream for uploading
Name | Type | Description |
---|---|---|
container |
String
|
Container name |
file |
String
|
File name |
[options] |
Object
|
Options for uploading |
Callback |
callback
|
function |
Name | Type | Description |
---|---|---|
err |
String or Object
|
Error string or object |
Name | Type | Description |
---|---|---|
result |
Stream
|
Stream for uploading |