module:api/files
- Description:
Files upload and retrieval
- Source:
Methods
(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 filesS3 is defined in api or options objects
- 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 | ||
flags |
string |
<optional> |
|
callback |
function |
<optional> |
(static) detectStore(file, outfile, options, callback)
- Description:
Detect file type and storee in one set
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | |
outfile |
string | |
options |
object | |
callback |
function |
(static) getUrl(file, options) → {string}
- Description:
Returns absolute file url if it is configured with any prefix or S3 bucket, otherwise returns empty string
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | |
options |
object |
Returns:
| Type | Description |
|---|---|
| string |
(static) list(options, callback)
- Description:
Returns a list of file names inside the given folder,
options.filtercan be a regexp to restrict which files to return
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object | |
callback |
function |
(static) put(req, name, options, callback)
- Description:
Upload file and store in the filesystem or S3, try to find the file in multipart form, in the body or query 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 or query |
||||||||||||||||||||||||||||||||||||||||
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 |
(static) read(file, options, 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 | Description |
|---|---|---|
file |
string | |
options |
object | |
callback |
function |
(static) send(req, file, options)
- Description:
Send a file to the client
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
req |
Request | |
file |
string | |
options |
object |
(static) store(tmpfile, outfile, options, callback)
- Description:
Place the uploaded tmpfile to the destination pointed by outfile
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tmpfile |
string | |
outfile |
string | |
options |
object | |
callback |
function |