Class: FileFactory

binding.FileFactory(propertiesopt, …arguments) → {binding.File}

new FileFactory(propertiesopt, …arguments) → {binding.File}

Parameters:
Name Type Attributes Description
properties Object <optional>

initial properties to set on the file

arguments * <repeatable>

Additional constructor params passed through the type constructor

Source:
Returns:

The new managed instance

Type
binding.File

Extends

Methods

create(db) → {binding.FileFactory}

Creates a new FileFactory for the given type

Parameters:
Name Type Description
db EntityManager
Source:
Returns:

A new file factory

Type
binding.FileFactory

fromJSON(json) → {binding.File}

Deserialize the file metadata from a json object back to a new file instance

Parameters:
Name Type Description
json json

The file metadata as json

Source:
Returns:

The deserialize File instance

Type
binding.File

listBuckets(doneCallbackopt, failCallbackopt) → {Promise.<Array.<binding.File>>}

Lists all the buckets.

Parameters:
Name Type Attributes Description
doneCallback binding.FileFactory~fileListCallback <optional>

The callback is invoked with the listed buckets

failCallback binding.File~failCallback <optional>

The callback is invoked if any error has occurred

Source:
Returns:

The listed buckets.

Type
Promise.<Array.<binding.File>>

listFiles(folderOrPath, start, count, doneCallbackopt, failCallbackopt) → {Promise.<Array.<binding.File>>}

Lists the files (and folders) in the given folder.

Parameters:
Name Type Attributes Description
folderOrPath binding.File | string

The folder/path to list.

start binding.File

The file/folder from where to start listing (not included)

count number

The maximum number of files to return.

doneCallback binding.FileFactory~fileListCallback <optional>

The callback is invoked with the listed files

failCallback binding.File~failCallback <optional>

The callback is invoked if any error has occurred

Source:
Returns:

The listed files/folders.

Type
Promise.<Array.<binding.File>>

loadMetadata(bucket, optionsopt, doneCallbackopt, failCallbackopt) → {Promise.<Object.<string, util.Permission>>}

Gets the metadata of the root folder (formally the file "bucket")

Parameters:
Name Type Attributes Description
bucket string

The name of the root file directory

options Object <optional>

The load metadata options

Properties
Name Type Attributes Default Description
refresh Object <optional>
false

Force a revalidation while fetching the metadata

doneCallback binding.FileFactory~bucketMetadataCallback <optional>

The callback is invoked after the metadata is fetched

failCallback binding.File~failCallback <optional>

The callback is invoked if any error has occurred

Source:
Returns:

A promise which will be fulfilled with the bucket acls

Type
Promise.<Object.<string, util.Permission>>

new(fileOptions) → {binding.File}

Creates a new file object which represents the file at the given ID

Data provided to the constructor will be uploaded by invoking upload().

Parameters:
Name Type Description
fileOptions object | string

The fileOptions used to create a new file object, or just the id of the
file object

Properties
Name Type Attributes Default Description
name string <optional>

The filename without the id. If omitted and data is provided as a file object,
the File#name will be used otherwise a uuid will be generated.

parent string <optional>
"/www"

The parent folder which contains the file

data string | Blob | File | ArrayBuffer | json

The initial file content, which will be uploaded by
invoking #upload later on.

type string <optional>

A optional type hint used to correctly interpret the provided data

mimeType string <optional>

The mimType of the file. Defaults to the mimeType of the provided data if
it is a file object, blob or data-url

eTag string <optional>

The optional current ETag of the file

lastModified string <optional>

The optional last modified date

acl Acl <optional>

The file acl which will be set, if the file is uploaded afterwards

headers Object.<string, string> <optional>

The custom headers which will be send with the file after
uploading it

Source:
Returns:

A new file instance

Type
binding.File

newInstance(argsopt) → {binding.File}

Creates a new file

Parameters:
Name Type Attributes Description
args Array.<*> <optional>

Constructor arguments used for instantiation, the constructor will not be called
when no arguments are passed

Source:
Returns:

A new created file

Type
binding.File

saveMetadata(bucket, metadata, doneCallbackopt, failCallbackopt) → {Promise.<void>}

Updates the metadata of the root file directory formally the file "bucket"

Parameters:
Name Type Attributes Description
bucket string

The name of the root file directory

metadata Object.<string, util.Permission>

The new metadata for the bucket

Properties
Name Type Attributes Description
load util.Permission <optional>

The load permission which grants read access to all stored
files under the specified bucket

insert util.Permission <optional>

The insert permission which is required to insert new
files into the bucket

update util.Permission <optional>

The update permission which is required to update existing
files within the bucket

delete util.Permission <optional>

The delete permission which is required to delete existing
files within the bucket

query util.Permission <optional>

The query permission which is required to list all files
within a bucket

doneCallback binding.FileFactory~bucketMetadataCallback <optional>

Invoked if the operation succeeds

failCallback binding.File~failCallback <optional>

The callback is invoked if any error has occurred

Source:
Returns:

A promise which will fulfilled with the updated metadata

Type
Promise.<void>

Type Definitions

bucketMetadataCallback(bucketMetadata) → {*}

The list files callback is called, with the bucket metadata

Parameters:
Name Type Description
bucketMetadata Object.<string, util.Permission>

the bucket metadata

Source:
Returns:

A Promise, result or undefined

Type
*

fileListCallback(files) → {*}

The list files callback is called, with the loaded files

Parameters:
Name Type Description
files Array.<binding.File>

The listed files

Source:
Returns:

A Promise, result or undefined

Type
*