18 KiB
wekan-cfs-file Public API
CollectionFS, FS.File object
API documentation automatically generated by docmeteor.
new fs.File([ref]) Anywhere
This method File is defined in FS
Arguments
- ref {object|FS.File|[data to attach](#data to attach)} (Optional)
Another FS.File instance, a filerecord, or some data to pass to attachData
FS.File = function(ref, createdByTransform) { ...fsFile-common.js:8
fsFile.attachData(data, [options], [callback]) Anywhere
This method attachData is defined in prototype of FS.File
Arguments
The data that you want to attach to the file.
- options {Object} (Optional)
Options
* __type__ *{String}* (Optional)
The data content (MIME) type, if known.
* __headers__ *{String}* (Optional)
When attaching a URL, headers to be used for the GET request (currently server only)
* __auth__ *{String}* (Optional)
When attaching a URL, "username:password" to be used for the GET request (currently server only)
- callback {Function} (Optional)
Callback function, callback(error). On the client, a callback is required if data is a URL.
Returns {FS.File} This FS.File instance.
FS.File.prototype.attachData = function fsFileAttachData(data, options, callback) { ...fsFile-common.js:36
fsFile.uploadProgress() Anywhere
This method uploadProgress is defined in prototype of FS.File
Returns {number} The server confirmed upload progress
FS.File.prototype.uploadProgress = function() { ...fsFile-common.js:154
fsFile.controlledByDeps() Anywhere
This method controlledByDeps is defined in prototype of FS.File
Returns {FS.Collection} Returns true if this FS.File is reactive
Note: Returns true if this FS.File object was created by a FS.Collection and we are in a reactive computations. What does this mean? Well it should mean that our fileRecord is fully updated by Meteor and we are mounted on a collection
FS.File.prototype.controlledByDeps = function() { ...fsFile-common.js:179
fsFile.getCollection() Anywhere
This method getCollection is defined in prototype of FS.File
Returns {FS.Collection} Returns attached collection or undefined if not mounted
FS.File.prototype.getCollection = function() { ...fsFile-common.js:189
fsFile.isMounted() Anywhere
This method isMounted is defined in prototype of FS.File
Returns {FS.Collection} Returns attached collection or undefined if not mounted
FS.File.prototype.isMounted = FS.File.prototype.getCollection;fsFile-common.js:217
fsFile.getFileRecord() Anywhere
This method getFileRecord is defined in prototype of FS.File
Returns {object} The filerecord
FS.File.prototype.getFileRecord = function() { ...fsFile-common.js:224
fsFile.update(modifier, [options], [callback]) Anywhere
This method update is defined in prototype of FS.File
Arguments
- modifier {modifier}
- options {object} (Optional)
- callback {function} (Optional)
Updates the fileRecord.
FS.File.prototype.update = function(modifier, options, callback) { ...fsFile-common.js:255
fsFile.remove([callback]) Anywhere
This method remove is defined in prototype of FS.File
Arguments
- callback {Function} (Optional)
Returns {number} Count
Remove the current file from its FS.Collection
FS.File.prototype.remove = function(callback) { ...fsFile-common.js:323
fsFile.getExtension([options]) Anywhere
Warning! This method "FS.File.prototype.getExtension" has deprecated from the API Use the
extensiongetter/setter method instead.
This method getExtension is defined in prototype of FS.File
Arguments
-
options {Object} (Optional)
- store {String} (Optional)
Store name. Default is the original extension.
Returns {string}
The extension eg.: jpg or if not found then an empty string ''
FS.File.prototype.getExtension = function(options) { ...fsFile-common.js:364
fsFile.isImage([options]) Anywhere
This method isImage is defined in prototype of FS.File
Arguments
-
options {object} (Optional)
- store {string} (Optional)
The store we're interested in
Returns true if the copy of this file in the specified store has an image content type. If the file object is unmounted or doesn't have a copy for the specified store, or if you don't specify a store, this method checks the content type of the original file.
FS.File.prototype.isImage = function(options) { ...fsFile-common.js:393
fsFile.isVideo([options]) Anywhere
This method isVideo is defined in prototype of FS.File
Arguments
-
options {object} (Optional)
- store {string} (Optional)
The store we're interested in
Returns true if the copy of this file in the specified store has a video content type. If the file object is unmounted or doesn't have a copy for the specified store, or if you don't specify a store, this method checks the content type of the original file.
FS.File.prototype.isVideo = function(options) { ...fsFile-common.js:408
fsFile.isAudio([options]) Anywhere
This method isAudio is defined in prototype of FS.File
Arguments
-
options {object} (Optional)
- store {string} (Optional)
The store we're interested in
Returns true if the copy of this file in the specified store has an audio content type. If the file object is unmounted or doesn't have a copy for the specified store, or if you don't specify a store, this method checks the content type of the original file.
FS.File.prototype.isAudio = function(options) { ...fsFile-common.js:423
fsFile.formattedSize({Object}, {String}, {String}) Anywhere
This method formattedSize is defined in prototype of FS.File
Arguments
- {Object} {any}
options
- {String} {any}
[options.store=none,display original file size] Which file do you want to get the size of?
- {String} {any}
[options.formatString='0.00 b'] The numeral format string to use.
Returns {String} The file size formatted as a human readable string and reactively updated.
You must add the numeral package to your app before you can use this method.
If info is not found or a size can't be determined, it will show 0.
FS.File.prototype.formattedSize = function fsFileFormattedSize(options) { ...fsFile-common.js:438
fsFile.isUploaded() Anywhere
This method isUploaded is defined in prototype of FS.File
Returns {boolean} True if the number of uploaded bytes is equal to the file size.
FS.File.prototype.isUploaded = function() { ...fsFile-common.js:456
fsFile.hasStored(storeName, [optimistic]) Anywhere
This method hasStored is defined in prototype of FS.File
Arguments
- storeName {string}
Name of the store
- optimistic {boolean} (Optional, Default = false)
In case that the file record is not found, read below
Returns {boolean} Is a version of this file stored in the given store?
Note: If the file is not published to the client or simply not found: this method cannot know for sure if it exists or not. The
optimisticparam is the boolean value to return. Are weoptimisticthat the copy could exist. This is the case inFS.File.urlwe are optimistic that the copy supplied by the user exists.
FS.File.prototype.hasStored = function(storeName, optimistic) { ...fsFile-common.js:478
fsFile.getCopyInfo(storeName) Anywhere
Warning! This method "FS.File.prototype.getCopyInfo" has deprecated from the API Use individual methods with
storeoption instead.
This method getCopyInfo is defined in prototype of FS.File
Arguments
- storeName {string}
Name of the store for which to get copy info.
Returns {Object} The file details, e.g., name, size, key, etc., specific to the copy saved in this store.
FS.File.prototype.getCopyInfo = function(storeName) { ...fsFile-common.js:504
fsFile.name([value], [options]) Anywhere
This method name is defined in prototype of FS.File
Arguments
- value {String|null} (Optional)
If setting the name, specify the new name as the first argument. Otherwise the options argument should be first.
-
options {Object} (Optional)
- store {Object} (Optional, Default = none,original)
Get or set the name of the version of the file that was saved in this store. Default is the original file name.
- updateFileRecordFirst {Boolean} (Optional, Default = false)
Update this instance with data from the DB first? Applies to getter usage only.
- save {Boolean} (Optional, Default = true)
Save change to database? Applies to setter usage only.
Returns {String|undefined}
If setting, returns undefined. If getting, returns the file name.
FS.File.prototype.name = function(value, options) { ...fsFile-common.js:568
fsFile.extension([value], [options]) Anywhere
This method extension is defined in prototype of FS.File
Arguments
- value {String|null} (Optional)
If setting the extension, specify the new extension (without period) as the first argument. Otherwise the options argument should be first.
-
options {Object} (Optional)
- store {Object} (Optional, Default = none,original)
Get or set the extension of the version of the file that was saved in this store. Default is the original file extension.
- updateFileRecordFirst {Boolean} (Optional, Default = false)
Update this instance with data from the DB first? Applies to getter usage only.
- save {Boolean} (Optional, Default = true)
Save change to database? Applies to setter usage only.
Returns {String|undefined}
If setting, returns undefined. If getting, returns the file extension or an empty string if there isn't one.
FS.File.prototype.extension = function(value, options) { ...fsFile-common.js:593
fsFile.size([value], [options]) Anywhere
This method size is defined in prototype of FS.File
Arguments
- value {Number} (Optional)
If setting the size, specify the new size in bytes as the first argument. Otherwise the options argument should be first.
-
options {Object} (Optional)
- store {Object} (Optional, Default = none,original)
Get or set the size of the version of the file that was saved in this store. Default is the original file size.
- updateFileRecordFirst {Boolean} (Optional, Default = false)
Update this instance with data from the DB first? Applies to getter usage only.
- save {Boolean} (Optional, Default = true)
Save change to database? Applies to setter usage only.
Returns {Number|undefined}
If setting, returns undefined. If getting, returns the file size.
FS.File.prototype.size = function(value, options) { ...fsFile-common.js:618
fsFile.type([value], [options]) Anywhere
This method type is defined in prototype of FS.File
Arguments
- value {String} (Optional)
If setting the type, specify the new type as the first argument. Otherwise the options argument should be first.
-
options {Object} (Optional)
- store {Object} (Optional, Default = none,original)
Get or set the type of the version of the file that was saved in this store. Default is the original file type.
- updateFileRecordFirst {Boolean} (Optional, Default = false)
Update this instance with data from the DB first? Applies to getter usage only.
- save {Boolean} (Optional, Default = true)
Save change to database? Applies to setter usage only.
Returns {String|undefined}
If setting, returns undefined. If getting, returns the file type.
FS.File.prototype.type = function(value, options) { ...fsFile-common.js:643
fsFile.updatedAt([value], [options]) Anywhere
This method updatedAt is defined in prototype of FS.File
Arguments
- value {String} (Optional)
If setting updatedAt, specify the new date as the first argument. Otherwise the options argument should be first.
-
options {Object} (Optional)
- store {Object} (Optional, Default = none,original)
Get or set the last updated date for the version of the file that was saved in this store. Default is the original last updated date.
- updateFileRecordFirst {Boolean} (Optional, Default = false)
Update this instance with data from the DB first? Applies to getter usage only.
- save {Boolean} (Optional, Default = true)
Save change to database? Applies to setter usage only.
Returns {String|undefined}
If setting, returns undefined. If getting, returns the file's last updated date.
FS.File.prototype.updatedAt = function(value, options) { ...fsFile-common.js:668
fsFile.createReadStream([storeName]) Server
This method createReadStream is defined in prototype of FS.File
Arguments
- storeName {String} (Optional)
Returns {stream.Readable} Readable NodeJS stream
Returns a readable stream. Where the stream reads from depends on the FS.File instance and whether you pass a store name.
If you pass a storeName, a readable stream for the file data saved in that store is returned.
If you don't pass a storeName and data is attached to the FS.File instance (on data property, which must be a DataMan instance), then a readable stream for the attached data is returned.
If you don't pass a storeName and there is no data attached to the FS.File instance, a readable stream for the file data currently in the temporary store (FS.TempStore) is returned.
FS.File.prototype.createReadStream = function(storeName) { ...fsFile-server.js:62
fsFile.createWriteStream([storeName]) Server
This method createWriteStream is defined in prototype of FS.File
Arguments
- storeName {String} (Optional)
Returns {stream.Writeable} Writeable NodeJS stream
Returns a writeable stream. Where the stream writes to depends on whether you pass in a store name.
If you pass a storeName, a writeable stream for (over)writing the file data in that store is returned.
If you don't pass a storeName, a writeable stream for writing to the temp store for this file is returned.
FS.File.prototype.createWriteStream = function(storeName) { ...fsFile-server.js:100
fsFile.copy() Server
This method copy is defined in prototype of FS.File
Returns {FS.File} The new FS.File instance
FS.File.prototype.copy = function() { ...fsFile-server.js:126