module:api/images
- Description:
Saving and serving images
- Source:
Methods
(static) del(id, options, callback)
- Description:
Delete an icon for user, .type defines icon prefix
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | |
options |
object | |
callback |
function |
(static) getPath(id, options) → {string}
- Description:
Full path to the icon, perform necessary hashing and sharding, id can be a number or any string.
- Source:
Parameters:
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
id |
string | |||||||||
options |
object |
Properties
|
Returns:
| Type | Description |
|---|---|
| string |
(static) getUrl(file, options) → {string}
- Description:
Returns constructed icon url from the icon record
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | |
options |
object |
Returns:
| Type | Description |
|---|---|
| string |
(static) isImage(buf) → {string}
- Description:
Returns detected image type if the given buffer contains an image, it checks the header only
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
buf |
buffer |
Returns:
| Type | Description |
|---|---|
| string |
(static) isUrl(url) → {boolean}
- Description:
Return true if the given file or url point ot an image
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string |
Returns:
| Type | Description |
|---|---|
| boolean |
(static) put(req, name, id, options, callback)
- Description:
Store an icon for user, the options are the same as for the
pathmethod
- 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 |
||||||||||||||||||||
id |
string | is used in |
||||||||||||||||||||
options |
object |
Properties
|
||||||||||||||||||||
callback |
function |
(static) save(file, id, options, callback)
- Description:
Save the icon data to the destination, if mod.s3 or options.imagesS3 specified then plave the image on the S3 drive. Store in the proper location according to the types for given id, this function is used after downloading new image or when moving images from other places. On success the callback will be called with the second argument set to the output file name where the image has been saved.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file |
string | |||||||||||||||||||||
id |
string | |||||||||||||||||||||
options |
object | same properties as in module:api/images.scale: width, height, filter, ext, quality Properties
|
||||||||||||||||||||
callback |
function |
(static) scale(infile, options, callback)
- Description:
Scale image return err if failed.
If image module is not set (default) then the input data is returned or saved as is.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
infile |
string | can be a string with file name or a Buffer with actual image data |
||||||||||||||||||||
options |
object |
Properties
|
||||||||||||||||||||
callback |
function | takes 3 arguments: function(err, data, info)
where |
(static) send(req, id, options)
- Description:
Send an icon to the client, only handles files
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
req |
Request | |
id |
string | |
options |
object |