module:files
Methods
(async, static) acopy(source, dest, options) → {Promise(object)}
- Description:
Async version of module:files.copy
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | |
dest |
string | |
options |
object |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
in format { err, data } |
(async, static) adel(file, options) → {Promise(object)}
- Description:
Async version of module:files.del
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | |
options |
object |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
in format { err, data } |
(async, static) adetect(file, flagsopt) → {Promise(object)}
- Description:
Async version of module:files.detect
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
file |
string | Buffer | ||
flags |
string |
<optional> |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
in format { err, data, ext } |
(async, static) adetectAndStore(file, outfile, options) → {Promise(object)}
- Description:
Async version of module:files.detectAndStore
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | Buffer | |
outfile |
string | |
options |
object |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
in format { err, data } |
(async, static) alist(options) → {Promise(object)}
- Description:
Async version of module:files.list
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
in format { err, data } |
(async, static) aread(file, options) → {Promise(object)}
- Description:
Async version of module:files.read
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | |
options |
object |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
in format { err, data } |
(async, static) astore(tmpfile, outfile, options) → {Promise(object)}
- Description:
Async version of module:files.store
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tmpfile |
string | Buffer | |
outfile |
string | |
options |
object |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
in format { err, data } |
(async, static) aupload(req, name, options) → {Promise(object)}
- Description:
Async version of module:files.upload
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
req |
Request | |
name |
string | |
options |
object |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
in format { err, data } |
(static) copy(source, dest, options, callback)
- Description:
Copy a file from one location to another, can deal with local and S3 files if starts with s3:// prefix
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | |
dest |
string | |
options |
object | |
callback |
function |
(static) del(file, options, callback)
- Description:
Delete file by name from the local filesystem or S3 drive if s3 is defined in api or options objects, no error is returned if the file does not exist to be compatible with S3 delete object
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | |
options |
object | |
callback |
function |
(static) detect(file, flagsopt, callbackopt)
- Description:
Returns detected mime type and ext for a file, using the "file" utility, flags can be passed to the
fileutility to customize the output
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
file |
string | Buffer | file or data |
|
flags |
string |
<optional> |
command line flags for the file utility (--mime-type) |
callback |
function |
<optional> |
(err, mimeType, ext) |
(static) detectAndStore(file, outfile, options, callback)
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | Buffer | |
outfile |
string | |
options |
object | |
callback |
function |
(static) list(options, callback)
- Description:
Returns a list of file names inside the given path or S3 bucket
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||||||
callback |
function |
(static) read(file, optionsopt, callback)
- Description:
Returns contents of a file, all specific parameters are passed as is, the contents of the file is returned to the callback, see module:lib.readFile or module.aws.s3GetFile for specific options.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file |
string | ||||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||
callback |
function |
(static) send(req, file, optionsopt)
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Request | Express request |
|||||||||||||||||
file |
string | file path |
|||||||||||||||||
options |
object |
<optional> |
Properties
|
(static) store(tmpfile, outfile, options, callback)
- Description:
Place the uploaded tmpfile to the destination pointed by outfile
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tmpfile |
string | Buffer | |
outfile |
string | |
options |
object | |
callback |
function |
(static) upload(req, name, options, callback)
- Description:
Upload file and store in the filesystem or S3, try to find the file in multipart form or in the body by the given name On return the options may have the following properties set:
- filesize - size of the file in bytes if available
- filetype - file extention with dot
- mimetype - file mime type if detected
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Request | |||||||||||||||||||||||||||||||||||||||||
name |
string | is the name property to look for in the multipart body or in the request body |
||||||||||||||||||||||||||||||||||||||||
options |
object | Output file name is built according to the following options properties: Properties
|
||||||||||||||||||||||||||||||||||||||||
callback |
function | will be called with err and actual filename saved |