internal.api.md 7.3 KB

Public and Private API

API documentation automatically generated by docmeteor.


File: "base-common.js" Where: {server|client}


#############################################################################

HELPERS

#############################################################################

_utility.defaultZero(val)  Anywhere

This method is private This method defaultZero is defined in _Utility

Arguments

  • val {Any}

Returns number or 0 if value is a falsy

_Utility.defaultZero = function(val) { ... base-common.js:42

-

fsUtility.cloneFileRecord(rec, [options])  Anywhere

This method cloneFileRecord is defined in FS.Utility

Arguments

  • rec {FS.File|FS.Collection filerecord}
  • options {Object} (Optional)

    • full {Boolean} (Optional, Default = false)

    Set true to prevent certain properties from being omitted from the clone.

Returns {Object} Cloned filerecord

Makes a shallow clone of rec, filtering out some properties that might be present if it's an FS.File instance, but which we never want to be part of the stored filerecord.

This is a blacklist clone rather than a whitelist because we want the user to be able to specify whatever additional properties they wish.

In general, we expect the following whitelist properties used by the internal and external APIs:

_id, name, size, type, chunkCount, chunkSize, chunkSum, copies, createdAt, updatedAt, uploadedAt

Those properties, and any additional properties added by the user, should be present in the returned object, which is suitable for inserting into the backing collection or extending an FS.File instance.

FS.Utility.cloneFileRecord = function(rec, options) { ... base-common.js:71

-

fsUtility.defaultCallback([err])  Anywhere

This method defaultCallback is defined in FS.Utility

Arguments

Returns {undefined}

Can be used as a default callback for client methods that need a callback. Simply throws the provided error if there is one.

FS.Utility.defaultCallback = function defaultCallback(err) { ... base-common.js:96

-

fsUtility.defaultCallback([f], [err])  Anywhere

This method defaultCallback is defined in FS.Utility

Arguments

  • f {Function} (Optional)

A callback function, if you have one. Can be undefined or null.

Error or error message (string)

Returns {Any} the callback result if any

Handle Error, creates an Error instance with the given text. If callback is a function, passes the error to that function. Otherwise throws it. Useful for dealing with errors in methods that optionally accept a callback.

FS.Utility.handleError = function(f, err, result) { ... base-common.js:120

-

fsUtility.noop()  Anywhere

This method noop is defined in FS.Utility

Use this to hand a no operation / empty function

FS.Utility.noop = function() { ... base-common.js:134

-

validateAction(validators, fileObj, userId)  Anywhere

This method is private

Arguments

  • validators {Object}

The validators object to use, with deny and allow properties.

Mounted or mountable file object to be passed to validators.

  • userId {String}

The ID of the user who is attempting the action.

Returns {undefined}

Throws a "400-Bad Request" Meteor error if the file is not mounted or a "400-Access denied" Meteor error if the action is not allowed.

FS.Utility.validateAction = function validateAction(validators, fileObj, userId) { ... base-common.js:147

-

fsUtility.getFileName(name)  Anywhere

This method is private This method getFileName is defined in FS.Utility

Arguments

  • name {String}

A filename, filepath, or URL

Returns {String} The filename without the URL, filepath, or query string

FS.Utility.getFileName = function utilGetFileName(name) { ... base-common.js:187

-

fsUtility.getFileExtension(name)  Anywhere

This method getFileExtension is defined in FS.Utility

Arguments

  • name {String}

A filename, filepath, or URL that may or may not have an extension.

Returns {String} The extension or an empty string if no extension found.

FS.Utility.getFileExtension = function utilGetFileExtension(name) { ... base-common.js:205

-

fsUtility.setFileExtension(name, ext)  Anywhere

This method setFileExtension is defined in FS.Utility

Arguments

  • name {String}

A filename that may or may not already have an extension.

  • ext {String}

An extension without leading period, which you want to be the new extension on name.

Returns {String} The filename with changed extension.

FS.Utility.setFileExtension = function utilSetFileExtension(name, ext) { ... base-common.js:222


File: "base-server.js" Where: {server}


fsUtility.binaryToBuffer(data)  Server

This method binaryToBuffer is defined in FS.Utility

Arguments

  • data {Uint8Array}

Returns {Buffer}

Converts a Uint8Array instance to a Node Buffer instance

FS.Utility.binaryToBuffer = function(data) { ... base-server.js:9

-

fsUtility.bufferToBinary(data)  Server

This method bufferToBinary is defined in FS.Utility

Arguments

  • data {Buffer}

Returns {Uint8Array}

Converts a Node Buffer instance to a Uint8Array instance

FS.Utility.bufferToBinary = function(data) { ... base-server.js:26


File: "base-client.js" Where: {client}


fsUtility.eachFile(e, f)  Client

This method eachFile is defined in FS.Utility

Arguments

Browser event

  • f {Function}

Function to run for each file found in the event.

Returns {undefined}

Utility for iteration over files in event

FS.Utility.eachFile = function(e, f) { ... base-client.js:37