Appearance
$io.fs
Server API reference.
Functions
- $io.fs.compressAndCreateFromUrl
- $io.fs.compressFile
- $io.fs.copyFile
- $io.fs.createFileFromBuffer
- $io.fs.createFileFromStream
- $io.fs.createFileFromText
- $io.fs.createFileFromUrl
- $io.fs.deleteFile
- $io.fs.deleteFiles
- $io.fs.getFileDownloadUrl
- $io.fs.getPublicFileDownloadUrl
- $io.fs.listFiles
- $io.fs.lookupFile
- $io.fs.readFileAsBuffer
- $io.fs.readFileAsStream
- $io.fs.readFileAsText
$io.fs.compressAndCreateFromUrl
Download, compress a image from a URL, and save it to cloud storage.
Usage
js
$io.fs.compressAndCreateFromUrl(path, url, isPublic, tinyfyApiKey, tinyfyOptions)Description
This function downloads a image from a specified URL, compresses it using the Tinyfy API, and saves it to the given path in cloud storage.
Usage Scenarios
- Automatically download and optimize images from external sources
- Reduce file sizes of images before saving to cloud storage
- Integrate image compression into an automated workflow for web assets
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
url
Type: String
Required: Yes
The url to read/download the file from
isPublic
Type: Boolean
Required: Yes
To create a file in your app's publicly accessible cloud storage set this value to true. Use false if you want the file to be saved in your app's private cloud storage.
tinyfyApiKey
Type: String
Required: Yes
The API key for the Tinyfy service, required for accessing the compression API.
tinyfyOptions
Type: Object
Required: Yes
Optional parameters for configuring the compression process (e.g., resize options, conversion options, etc.).
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- Location: The path of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.compressFile
Compress a image file from a source path and save it to a destination path in cloud storage.
Usage
js
$io.fs.compressFile(srcPath, srcIsPublic, dstPath, dstIsPublic, tinyfyApiKey, tinyfyOptions)Description
This function compresses a image file located at a source path in cloud storage and saves the compressed version to a destination path. The function uses the Tinyfy API to perform image compression and allows for customization of the options.
Usage Scenarios
- Optimize large images files for faster loading or storage efficiency
- Compress files for backup while reducing storage costs
- Automate file compression
Parameters
srcPath
Type: String
Required: Yes
The path of the image file to be compressed, including directory and file name (e.g., '/source/file.jpg').
srcIsPublic
Type: Boolean
Required: Yes
Specifies whether the source file is publicly accessible (true) or private (false).
dstPath
Type: String
Required: Yes
The path where the compressed file will be saved, including directory and file name (e.g., '/destination/compressed.jpg').
dstIsPublic
Type: Boolean
Required: Yes
Specifies whether the destination file should be publicly accessible (true) or private (false).
tinyfyApiKey
Type: String
Required: Yes
The API key for the Tinyfy service, required for accessing the compression API.
tinyfyOptions
Type: Object
Required: Yes
Optional parameters for configuring the compression process (e.g., resize options, conversion options, etc.).
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- Location: The path of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.copyFile
Copy a file from one location to another in cloud storage
Usage
js
$io.fs.copyFile(srcPath, srcIsPublic, dstPath, dstIsPublic)Description
This function copies a file from a source path to a destination path within cloud storage.
Usage Scenarios
- Duplicate files between different directories in cloud storage
- Move files from a private directory to a public directory or vice versa
- Backup important files by copying them to a separate location
Parameters
srcPath
Type: String
Required: Yes
The source file's path in cloud storage, including directory and file name (e.g., '/source/file.txt').
srcIsPublic
Type: Boolean
Required: Yes
Specifies whether the source file is publicly accessible (true) or private (false).
dstPath
Type: String
Required: Yes
The destination file's path in cloud storage, including directory and file name (e.g., '/destination/file.txt').
dstIsPublic
Type: Boolean
Required: Yes
Specifies whether the destination file should be publicly accessible (true) or private (false).
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- Location: The path of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
$io.fs.createFileFromBuffer
Create a file in cloud storage using a buffer
Usage
js
$io.fs.createFileFromBuffer(path, buffer, contentType, isPublic)Description
Creates a file in cloud storage with the contents of the specified buffer. This function is useful when you want to save binary data (e.g., images, audio, or other non-text data) directly from a buffer into the cloud storage.
Usage Scenarios
- Generate binary files dynamically and save
- Store files received from external services
- Save non-text data like PDFs, ZIP files, or executables
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
buffer
Type: Object
Required: Yes
A Buffer object containing the contents to be written to the file
contentType
Type: String
Required: Yes
The MIME content type. application/octet-stream will be used if an empty content type is provided.
isPublic
Type: Boolean
Required: Yes
To create a file in your app's publicly accessible cloud storage set this value to true. Use false if you want the file to be saved in your app's private cloud storage.
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- Location: The path of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.createFileFromStream
Create a file in cloud storage using a Readable stream
Usage
js
$io.fs.createFileFromStream(path, stream, contentType, size, isPublic)Description
Creates a file in cloud storage with the contents of the specified Readable stream. This function is commonly used for handling large files by streaming data in chunks.
Usage Scenarios
- Read binary data from a stream and save to cloud storage
- Store files received from external services
- Save non-text data like PDFs, ZIP files, or executables
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
stream
Type: Object
Required: Yes
A stream.Readable object containing the contents to be written to the file
contentType
Type: String
Required: Yes
The MIME content type. application/octet-stream will be used if an empty content type is provided.
size
Type: Number
Required: Yes
The expected size of the file in bytes. This is used for file meta data. If unavailable, you can specify 0.
isPublic
Type: Boolean
Required: Yes
To create a file in your app's publicly accessible cloud storage set this value to true. Use false if you want the file to be saved in your app's private cloud storage.
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- Location: The path of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.createFileFromText
Create a file in cloud storage using the specified text
Usage
js
$io.fs.createFileFromText(path, text, contentType, isPublic)Description
Creates a file in cloud storage with the contents of the specified text.
Usage Scenarios
- Save text contents to a file in cloud storage
- Save logs or reports
- Store form submissions as text
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
text
Type: String
Required: Yes
The text content to write to the file
contentType
Type: String
Required: Yes
The MIME content type. text/plain will be used if an empty content type is provided.
isPublic
Type: Boolean
Required: Yes
To create a file in your app's publicly accessible cloud storage set this value to true. Use false if you want the file to be saved in your app's private cloud storage.
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- Location: The path of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.createFileFromUrl
Copy a file from a specified URL to cloud storage
Usage
js
$io.fs.createFileFromUrl(path, url, isPublic)Description
This function downloads a file from a given URL and saves it to the specified path in cloud storage. The size and the contentType are determined automatically and are saved as meta data for the file.
Usage Scenarios
- Download files from a remote server and store them in cloud storage
- Store files received from external services in cloud storage
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
url
Type: String
Required: Yes
The url to read/download the file from
isPublic
Type: Boolean
Required: Yes
To create a file in your app's publicly accessible cloud storage set this value to true. Use false if you want the file to be saved in your app's private cloud storage.
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- Location: The path of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.deleteFile
Delete a file from cloud storage.
Usage
js
$io.fs.deleteFile(path, isPublic)Description
This function deletes a file from the specified path in cloud storage.
Usage Scenarios
- Remove outdated or unnecessary files from cloud storage
- Automatically delete temporary files after processing
- Clean up storage by removing user-specific files on request
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
isPublic
Type: Boolean
Required: Yes
Specifies whether the file is publicly accessible (true) or private (false).
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.deleteFiles
Delete multiple files from cloud storage.
Usage
js
$io.fs.deleteFiles(pathArray, isPublic)Description
This function deletes multiple files from cloud storage based on an array of paths.
Usage Scenarios
- Batch delete outdated or unnecessary files from cloud storage
- Automate the removal of a list of temporary files after processing
- Clean up storage by removing multiple user-specific files in one go
Parameters
pathArray
Type: Array
Required: Yes
Each element of the Array can either be a String representing the path of the file to be deleted, or an Object with the 'path' property representing the path of the file to be deleted.
isPublic
Type: Boolean
Required: Yes
Specifies whether the files are publicly accessible (true) or private (false).
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.getFileDownloadUrl
Get the URL for a file in the public or private cloud storage
Usage
js
$io.fs.getFileDownloadUrl(path, isPublic, expires)Description
Get the URL string for a file in your app's cloud storage. The URL can be used to access or download the file.
Usage Scenarios
- Get the URL for a file in cloud storage
- Download a file in cloud storage
- Generate temporary download links for private files
- Secure file-sharing for private files
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
isPublic
Type: Boolean
Required: Yes
If the file os part of your app's publicly accessible cloud storage set this value to true. In this case the function behaves similarly to the $io.fs.getPublicFileDownloadUrl function. Use false if the file is part of your app's private cloud storage.
expires
Type: Number
Required: Yes
For files in the private cloud storage, this parameter specfies the number of seconds the URL will be valid. The minimum valid value is 1 second and a maximum value is 43200 seconds (12 hours). This parameter is ignored if the isPublic parameter is set to true.
Output
Type: Promise
This function returns a Promise that resolves to a String representing the URL of the provided path.
Related Functions
$io.fs.getPublicFileDownloadUrl
Get the URL for a file in the publicly accessible cloud storage
Usage
js
$io.fs.getPublicFileDownloadUrl(path)Description
Returns a URL string for a file in your app's publicly accessible cloud storage. The URL can be used to access or download the file.
Usage Scenarios
- Get the URL for a file in publicly accessible cloud storage
- Download a public file in cloud storage
- Share a public file with users via a link
- Generate download links for public files
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
Output
Type: String
The URL of the provided path.
Related Functions
$io.fs.listFiles
List files saved in the cloud storage
Usage
js
$io.fs.listFiles(pathPrefix, isPublic)Description
Retrieves a list of files saved in the cloud storage that matches the specified path prefix.
Usage Scenarios
- Get a list of files in the cloud storage
- List directory contents in cloud storage
- Find out what files are stored in cloud storage
- Browse cloud directories
- Monitor file uploads
- Filter and search files by path prefix
Parameters
pathPrefix
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
isPublic
Type: Boolean
Required: Yes
If the file is part of your app's publicly accessible cloud storage set this value to true. Use false if the file is part of your app's private cloud storage.
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- name: The path of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.lookupFile
Retrieve information about a file in cloud storage
Usage
js
$io.fs.lookupFile(path, isPublic)Description
Retrieves information about a file in cloud storage. Information includes the name, size, MIME content type, etc.'
Usage Scenarios
- Get information about a file in cloud storage
- Find out the size of a file in cloud storage
- Find out the MIME content-type of a file in cloud storage
- Check file accessibility and status
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
isPublic
Type: Boolean
Required: Yes
If the file is part of your app's publicly accessible cloud storage set this value to true. Use false if the file is part of your app's private cloud storage.
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- data: If successful, an object representing the information about the file. The following properties are provided:
- name: The name of the file
- size: The size of the file in bytes
- contentType: The MIME content type for the file
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.readFileAsBuffer
Read the contents of a file from cloud storage and return it as a Buffer object.
Usage
js
$io.fs.readFileAsBuffer(path, isPublic)Description
This function reads the contents of a file from the specified path in cloud storage and returns the file as a Buffer object.
Usage Scenarios
- Retrieve binary files such as images, PDFs, or media files for further processing
- Read files that are not text-based, such as executables or archives
- Download files from cloud storage and manipulate their content as raw data
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
isPublic
Type: Boolean
Required: Yes
Specifies whether the source file is publicly accessible (true) or private (false).
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- contentType: The MIME content type of the file.
- data: If successful, a Buffer object containing the file's data
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.readFileAsStream
Read the contents of a file from cloud storage and return it as a Readable stream.
Usage
js
$io.fs.readFileAsStream(path, isPublic)Description
This function reads the contents of a file from the specified path in cloud storage and returns it as a stream.Readable object.
Usage Scenarios
- Stream large files such as videos or large documents without loading them entirely into memory
- Read files in chunks for processing, such as line-by-line or chunk-by-chunk
- Handle large file downloads by streaming their content for efficient resource usage
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
isPublic
Type: Boolean
Required: Yes
Specifies whether the source file is publicly accessible (true) or private (false).
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- contentType: The MIME content type of the file.
- data: If successful, a stream.Readable object containing the file's data.
- err: If successful set to null, otherwise the information about the error (usually as a string).
Related Functions
$io.fs.readFileAsText
Read the contents of a file from cloud storage and return it as a text string.
Usage
js
$io.fs.readFileAsText(path, isPublic)Description
This function reads the contents of a file from the specified path in cloud storage and returns the file content as a text string.
Usage Scenarios
- Retrieve and display the content of text-based files (e.g., .txt, .json, .html)
- Read text files or logs stored in cloud storage
Parameters
path
Type: String
Required: Yes
The file's path in the form /parent-dir/child-dir/file-name or /dir/file-name, etc.
isPublic
Type: Boolean
Required: Yes
Specifies whether the source file is publicly accessible (true) or private (false).
Output
Type: Promise
This function returns a Promise that resolves to an object with the following properties:
- status: A Boolean value of true if the operation was successful or false otherwise.
- contentType: The MIME content type of the file.
- data: If successful, a String containing the file's data
- err: If successful set to null, otherwise the information about the error (usually as a string).

