The JSMA file provides functionality for handling files
What can JSMA file do for me?You could easily use the JSMA file to edit a file |
Here is an example on how to write data to a JSMA file:
... file.setReferenceCount(7); ... |
Here is an example on how to read data from a JSMA file:
... if file.has('description') { ... } ... |
The JSMA file provides the following methods:
Clones the file and returns the copy as a JSMA file with a new uuid.
This entity is slice aware, which means that to use this facility:
|
... var copiedFile = file.clone() // => file ... |
Returns the content of a file as string
... var filecontent = file.content ... |
Decreases and reloads the reference count.
... file.decrementReferenceCount(); ... |
Deletes a given file (cannot be undone).
... file.delete() ... |
Returns the object's file name.
... var fname = file.fileName; ... |
Returns an array of the flex attributes of a file
... var flexAttribute = file.flexAttributes; ... |
Returns a string that you can use in the fragment cache. This string will change whenever the file is changed.
... file.cacheKey # => "12589387317632578294" ... |
Returns the value of key as string or null if no value is set under the key.
... var keyvalue = file.get(key); ... |
The key to be looked up in the flexAttributes of the file.
Returns a boolean value depending on whether key is present for a given file
... if file.has('description') { ... } ... |
The key to be checked in the flexAttributes of the file.
Returns the height attribute for a given file.
... var height = file.height; ... |
Returns a human-readable file size with a precision of two decimal places.
... var humanSize= file.humanSize(); // => 5 MB ... |
Returns the ID of a file.
... var id = file.id; ... |
Native Dragonfly file URL
... var imgPath = file.imagePath(10, 5); ... |
Increments the vale of a given key by one.
... file.increment("amount"); ... |
The key to be incremented in the flexAttributes of the file.
Increases and reloads the reference count.
... file.incrementReferenceCount(); ... |
Returns the path of a file.
... var path = file.location; ... |
Returns the name of a file.
... var filename = file.name; ... |
Returns the namespace that a file belongs to.
... fileNamespace = file.namespace; ... |
Native unresized Dragongfly URL to the file
... var fileURL = file.path; ... |
Prepares the thumbnail for a given file.
... file.prepareResizedImage(size) ... |
Returns the current reference count for a given file.
... var refCount = file.referenceCount(); ... |
Removes the key from the flexAttributes of the file
... file.remove("description"); ... |
The key to be removed from the flexAttributes of the file.
Generates a resized temporary version of an image.
These are the image modifications you can do with this function:
... file.resizedImage(size, [intermediate_size], [jpeg_quality]); ... |
An Imagemagick geometry string.
An Imagemagick geometry string.
This size will be used as the intermediate size from which the image will be created. Another resizing step is done unless the intermediate size image has already been generated.
The jpeg quality (0-100)
Whether to strip all EXIF data from the file. Applicable only for jpeg files. This step will be skipped for non-jpeg files.
The new image format.
The Imagemagick scaling mode. Defaults to 'scale'
Transparent parts will be filled with this color.
Example: 'white', '#ff000f'
One or more Imagemagick command line parameters.
Example: '+level-colors "#acd321","#abc123"'
Sets the value of a specified key for a given file.
... file.set(key, value, [options]); ... |
The key to be set in the flexAttributes of the file.
The value to be set for the key
May have a key 'broadcastEvent':bool which determines whether the log message shows up in the websocket log view.
Sets the content of a file
This entity is slice aware, which means that to use this facility:
|
... file.setContent(file, [options]); ... |
Sets the file name to the specified parameter.
This entity is slice aware, which means that to use this facility:
|
... file.setName(name); ... |
The name that should be used
Sets the namespace a file belongs in to the specified parameter.
This entity is slice aware, which means that to use this facility:
|
... file.setNamespace(namespaceOrId); ... |
Sets the reference count of a file to the specified parameter.
... file.setReferenceCount(7); ... |
The number of references that should be set
Sets the type for a given file.
... file.setType(new_type) ... |
The new type for the file, that should be used
Returns the filesize for a given file.
... var filesize = file.size; ... |
Returns an array of tags for a given file.
... var filetags = file.tags; ... |
Returns the type of a given file.
... var filetype = file.type; ... |
Updates the file
This entity is slice aware, which means that to use this facility:
|
... file.update({ name: 'new.file.name.jpg' }) ... |
Returns the UUID for a given file.
... var fileUUID = file.uuid; ... |
Returns the width for a given file.
... var fileWidth = file.width; ... |
Registers the file with the IBS.
... file.promoteIBS() ... |
The IBS-Options. See the IBS Entity Documentation for possible values.
Updates the file's IBS-Options in the remote IBS instance.
... file.updateIBS({ description: 'my file description' }); ... |
The IBS-Options. See the IBS Entity Documentation for possible values.
Unregisters the file from the IBS.
... file.deleteIBS() ... |
Removes the local file. On next access it will be retrieved from IBS if possible.
... file.deleteLocal() ... |
Returns whether the file is registered with IBS.
... var isIBS = file.isIBS; # => true ... |
Returns the JSMA entity of the file.
... var entity = file.getIBSEntity(); ... |