FileStore
The FileStore class is used to find, save, update, remove, count and group files.
Method Summary
Public Methods | ||
public |
Download a file. |
|
public |
downloadByUrl(url: string, options: Object): Promise<string> Download a file using a url. |
|
public |
Finds all files. |
|
public |
findById(id: *, options: *): * |
|
public |
removeById(id: *, options: {}): * |
|
public |
Stream a file. |
|
public |
Upload a file. |
Public Methods
public download(name: string, options: Object): Promise<string> source
Download a file.
Params:
Name | Type | Attribute | Description |
name | string |
|
_id of the file to download. |
options | Object |
|
Options |
options.tls | boolean |
|
By default, all requests to retrieve files are made with https. By setting this flag to false, files are retrieved over unsecure http connections. |
options.ttl | number |
|
Specify a time to live for the _downloadURL to limit the amount of time the download url is valid. |
public downloadByUrl(url: string, options: Object): Promise<string> source
Download a file using a url.
public find(query: Query, options: Object): Promise<Object[]> source
Finds all files. A query can be optionally provided to return a subset of all the files for your application or omitted to return all the files. The number of files returned will adhere to the limits specified at http://devcenter.kinvey.com/rest/guides/datastore#queryrestrictions. A promise will be returned that will be resolved with the files or rejected with an error.
Params:
Name | Type | Attribute | Description |
query | Query |
|
Query used to filter result. |
options | Object |
|
Options |
options.tls | boolean |
|
By default, all requests to retrieve files are made with https. By setting this flag to false, files are retrieved over unsecure http connections. |
options.ttl | number |
|
Specify a time to live for the _downloadURL to limit the amount of time the download url is valid. |
options.download | boolean |
|
Download the files |
public findById(id: *, options: *): * source
Params:
Name | Type | Attribute | Description |
id | * | ||
options | * |
Return:
* |
public removeById(id: *, options: {}): * source
Params:
Name | Type | Attribute | Description |
id | * | ||
options | {} |
|
Return:
* |
public stream(name: string, options: Object): Promise source
Stream a file. A promise will be returned that will be resolved with the file or rejected with an error.
Params:
Name | Type | Attribute | Description |
name | string | File name |
|
options | Object |
|
Options |
options.tls | Boolean |
|
Use Transport Layer Security |
options.ttl | Number |
|
Time To Live (in seconds) |
options.dataPolicy | DataPolicy |
|
Data policy |
options.authType | AuthType |
|
Auth type |
Example:
var files = new Kinvey.Files();
files.stream('BostonTeaParty.png', {
tls: true, // Use transport layer security
ttl: 60 * 60 * 24, // 1 day in seconds
}).then(function(file) {
...
}).catch(function(err) {
...
});