files

files

Methods

(static) downloadUrl(type, id, params)

Source:
Get a valid download url for a specified record
Example
const url = sdk.files.downloadUrl('image', '61eca4746971e75c1fc670cf', {w:100, h:100});
// https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&h=100&download=true

const url = sdk.files.downloadUrl('image', {_id:'61eca4746971e75c1fc670cf'...}, {f:'png'});
// https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&h=100&download=true
Parameters:
Name Type Description
type String The type or definition of the item we want to generate the url for
id Object | String The id or object with an _id property that we want to generate the url for
params Object Additional parameters and options for the url

(static) filesize(bytes)

Source:
Convert bytes to a human readable file size
Example
const size = sdk.files.filesize(1500);
// 1.5kb
Parameters:
Name Type Description
bytes Integer The number of bytes

(static) getBinaryTypeFromMime(fileMime)

Source:
Get the basic primitive type of a file from it's mime type value
Example
const type = sdk.files.getBinaryTypeFromMime('image/svg+xml');
// 'image'

const type = sdk.files.getBinaryTypeFromMime('video/webm');
// 'video'
Parameters:
Name Type Description
fileMime String The mime type of the file

(static) mediaUrl(type, id, params)

Source:
Get a valid media url for a specified image, video or audio item
Example
const url = sdk.files.mediaUrl('image', '61eca4746971e75c1fc670cf', {w:100, h:100});
// https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&h=100&download=true

const url = sdk.files.mediaUrl('image', {_id:'61eca4746971e75c1fc670cf'...}, {f:'png'});
// https://api.qik.dev/image/61eca4746971e75c1fc670cf?w=100&h=100&download=true
Parameters:
Name Type Description
type String The type or definition of the item we want to generate the url for
id Object | String The id or object with an _id property that we want to generate the url for
params Object Additional parameters and options for the url