Filesystem
This module must be enabled under "Plugins" in the Deskifier Dashboard
Methods
Request Download
Requests a download to the device. When the download starts, the Download Started event will fire.
await window.deskifier.filesystem.requestDownload({ arguments })
Arguments
urlString (Required)
The file to download. Must be from a https domain.dialogOptionsElectron.SaveDialogOptions (Optional)
Optional "save as" dialog options, to customize the dialog window that is shown.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Pause Download
Pauses an active download.
Some paused downloads may not be able to be resumed, depending on the web server. In this case, the download will restart.
await window.deskifier.filesystem.pauseDownload({ arguments })
Arguments
downloadIdString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Resume Download
Resumes a paused download.
Some paused downloads may not be able to be resumed, depending on the web server. In this case, the download will restart.
await window.deskifier.filesystem.resumeDownload({ arguments })
Arguments
downloadIdString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Cancel Download
Cancels a download.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.cancelDownload({ arguments }) </strong></code></pre>
Arguments
downloadIdString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Read Directory
Reads the contents of the given directory.
await window.deskifier.filesystem.readDirectory({ arguments })
Arguments
pathString (Required)
Which directory to read. Will return an error if directory can't be found.
Returns
filesArraynameString
Name of the file.isDirectoryBooleanisFileBooleanfileExtensionStringdirectoryStringfullPathString
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Example
const files = await window.deskifier.filesystem.readDirectory({ path: directory });
console.log(files.files)
/*
[
{
name: 'example.txt',
isDirectory: false,
isFile: true,
fileExtension: '.txt',
directory: 'C:/Users/Example/Documents',
fullPath: 'C:/Users/Example/Documents/example.txt'
},
{
name: 'images',
isDirectory: true,
isFile: false,
fileExtension: '',
directory: 'C:/Users/Example/Documents',
fullPath: 'C:/Users/Example/Documents/images'
}
]
*/
Create Directory
Creates a new directory in a given directory.
await window.deskifier.filesystem.createDirectory({ arguments })
Arguments
pathString (Required)
Where to create the new directory.dirNameString (Required)
The new name of the directory.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Example
const args = {
path: "C:\\Users\\Example\\Desktop",
dirName: "Example Folder"
};
await window.deskifier.filesystem.createDirectory(args);
Upload File
Sets the value of a file uploader input.
Instead of handling the process of uploading the file from the device to the destination, this function allows you to set the value of a web file uploader programmatically.
This isn't normally possible in browsers, however, the electron app has special capabilities enabled to override these restrictions.
This allows developers to use existing file upload methods; it improves the reliability of file uploads and makes handling errors easier.
Limited to whitelisted directories, without custom code signing certificates.
await window.deskifier.filesystem.uploadFile({ arguments })
Arguments
windowIDString (Optional)
Which Deskifier window to target. Defaults to the sender window.filePathsArray of Strings (Required)
Which files to upload.selectorString (Required)
The selector of the input. If multiple matches are found, the first item will be used. Will return an error if a file uploader input can't be found.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Example
<pre class="language-javascript" data-overflow="wrap"><code class="lang-javascript"><strong>window.deskifier.filesystem.uploadFile({ </strong> windowID: "window-1", filePaths: ['C:\Users\Example\Desktop\exampleFile.png'], selector: '#fileUploader' }) </code></pre>
Show In Folder
Attempts to show the given file in a file manager, and if possible, selects the file.
await window.deskifier.filesystem.showInFolder({ arguments })
Arguments
pathString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Trash File
Attempts to move a file or directory to the recycle bin.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.trashFile({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file/directory to trash.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful
Read File
Attempts to read the file, and return data as a string.
This reads the full content of the file in memory before returning the data.
This means that big files are going to have a major impact on your memory consumption and can lead to crashes.
Use this in tandem with the Get Stats method to make sure the file is small in size.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.readFile({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file to read.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessfulcontentString
The file's contents, decoded as UTF-8.
Create Thumbnail
Creates a thumbnail from the file, and returns it as base64. Can be used to preview images & videos.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.createThumbnail({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file to generate a thumbnail for.sizeObject (Required)
Target dimensions for the thumbnail.widthNumberheightNumber
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessfuldataURLString
Base64-encoded image data URL of the thumbnail.
Create File
Creates an empty file, for you to write data to.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.createFile({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the new file. The function will fail if a file already exists at the given path.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessfulfilePathString
The path to the newly created file.
Write File
Overwrites a file's contents.
This method isn't intended for large files, rather smaller files like .json or .txt files.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.writeFile({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file to write to.contentString (Required)
What to write to the file.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful
Rename File
Renames a file or directory.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.renameFile({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file to rename.newFileNameString (Required)
The name of the new file.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful
Move File
Moves a file or directory from one location to another.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.moveFile({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file to move.destinationPathString (Required)
Where to move the file to.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful
Get File Stats
Gets stats about the file like size, creation date, etc.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.getStats({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file to check.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessfulstatsObjectsizeNumber
File size in bytes.sizeHumanString
File size as readable format (ex. "1mb")pathString
Absolute path to the file.extensionString
File extension including the leading dot (ex. ".txt").parentDirectoryStringfileNameStringisFileBooleanisDirectoryBooleancreatedAtString
ISO-formatted creation timestamp.modifiedAtString
ISO-formatted modification timestamp.accessedAtString
ISO-formatted last-access timestamp.
Check Access
Checks permissions for a given file or directory
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.checkAccess({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file/directory to check.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessfulpermissionsObjectreadableBooleanwritableBooleanexecutableBoolean
isInAllowedDirectoryBoolean
Whether the path is inside Deskifier's filesystem access allowlist.
Watch Path
Watches a directory or file for changes. Will fire the Path Changed event.
Be sure to "unwatch" when a watch is no longer needed, for performance reasons.
Limited to whitelisted directories, without custom code signing certificates.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.watch({ arguments }) </strong></code></pre>
Arguments
pathString (Required)
The path of the file/directory to watch.recursiveBoolean (Optional)
Specify if all the subdirectories of the given directory should be watched. The default value is false.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessfulwatchIdString
The ID of the watch job.
Unwatch Path
Stops observing a file/directory for changes.
Be sure to "unwatch" when a watch is no longer needed, for performance reasons.
<pre class="language-javascript"><code class="lang-javascript"><strong>await window.deskifier.filesystem.unwatch({ arguments }) </strong></code></pre>
Arguments
watchIdString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful
Node Path Tools
A collection of node.js path tools to help modify & construct paths.
Basename
Extracts the last part of a path (the filename).
await window.deskifier.filesystem.path.basename(path, [ext])
Extname
Extracts the file extension (including the leading dot).
await window.deskifier.filesystem.path.extname(path)
Join
Joins path segments together, using the platform-specific separator.
await window.deskifier.filesystem.path.join(...paths)
Relative
Finds the relative path between one path and another.
await window.deskifier.filesystem.path.relative(from, to)
Normalize
Resolves incorrect platform-specific separators, resolves .. (parent directory) and . (current directory) segments, and handles extra separators.
await window.deskifier.filesystem.path.normalize(path)
Resolve
Resolves a sequence of paths or path segments into an absolute path. It treats each argument from right to left, prepending it to the path until an absolute path is constructed.
await window.deskifier.filesystem.path.resolve(...pathSegments)
Dirname
Returns the directory name of a path. This is equivalent to removing the last part of a path.
await window.deskifier.filesystem.path.dirname(path)
Separator
Returns the platform-specific path segment separator\ on Windows / on POSIX
await window.deskifier.filesystem.path.sep()
Examples
await window.deskifier.filesystem.path.basename('C:\\Users\\Example\\file.txt');
//file.txt
await window.deskifier.filesystem.path.extname('C:\\Users\\Example\\file.txt');
//.txt
await window.deskifier.filesystem.path.join('Users', 'Example', 'file.txt');
//C:\\Users\\Example\\file.txt
await window.deskifier.filesystem.path.relative('C:\\Users\\Example\\file.txt', 'C:\\Users\\User\\file.txt');
//..\\..\\User\\file.txt
await window.deskifier.filesystem.path.normalize('C:/Users/Example/file.txt');
//C:\\Users\\Example\\file.txt
await window.deskifier.filesystem.path.resolve('C:\\Users\\Example','example.txt');
//C:\\Users\\Example\\example.txt
await window.deskifier.filesystem.path.dirname('C:\\Users\\Example');
//C:\\Users
Properties
Get Default Directories
Returns the default directories of the device.
These directories are whitelisted.
await window.deskifier.filesystem.getDefaultDirectories()
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessfuldirectoriesObjectdesktopStringdocumentsStringdownloadsStringmusicStringpicturesStringvideosStringappDataStringtempStringexeString
Path to the running Deskifier executable.
Example
<pre class="language-javascript"><code class="lang-javascript">const directories = await window.deskifier.filesystem.getDefaultDirectories(); <strong>console.log(directories.directories) </strong>/* { desktop: 'C:\Users\Example\Desktop', documents: 'C:\Users\Example\Documents', downloads: 'C:\Users\Example\Downloads', music: 'C:\Users\Example\Music', pictures: 'C:\Users\Example\Pictures', videos: 'C:\Users\Example\Videos', appData: 'C:\Users\Example\AppData\Roaming', temp: 'C:\Users\Example\AppData\Local\Temp', exe: 'C:\Users\Example\Program Files\DesktopApp\app.exe' } */ </code></pre>
Get Drives
Returns the available storage drives, and information about them.
await window.deskifier.filesystem.getDrives()
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessfuldrivesArray of ObjectsavailableNumber
Amount of storage available, in bytes.usedNumber
Amount of storage used, in bytes.sizeNumber
Total size of the disk or partition, in bytes.capacityString
Percent of the drive/partition that is utilized.filesystemString
The type of storage.mountedString
Location in the filesystem where the storage device is accessible.
Example
<pre class="language-javascript"><code class="lang-javascript">const drives = await window.deskifier.filesystem.getDrives(); <strong>console.log(drives.drives) </strong>/* [ { filesystem: 'Local Fixed Disk', size: 119387713536, used: 109906608128, available: 9481105408, capacity: '92%', <strong> mounted: 'C:\' </strong> }, { filesystem: 'CD-ROM Drive', size: 0, used: 0, available: 0, capacity: '0%', mounted: 'E:\' } ] */ </code></pre>
Get Allowed Paths
Returns the current filesystem allowlist — the directories, specific files, and individual folders the app is permitted to read/write. Useful for debugging permission errors.
await window.deskifier.filesystem.getAllowedPaths()
Returns
successBoolean
If the action was successful.directoryRootsArray of Strings
Root directories the app has broad access to (e.g. default folders like Documents/Downloads, plus any custom roots granted via the Deskifier dashboard).explicitFilesArray of Strings
Specific file paths the user has granted access to (via open dialogs, drag-and-drop, etc.).explicitDirectoriesArray of Strings
Specific directories the user has granted access to.
Events
Download Started
Fires when a download starts.
window.deskifier.filesystem.onDownloadStarted((downloadData) => {})
Arguments
idString
The download ID.savePathString
Where the download is being saved to.fileNameString
The name of the file being downloaded.mimeTypeString
The type of file being downloaded.stateString
Can beprogressing,completed,cancelledorinterrupted.percentCompletedNumber
Percent out of 100transferredBytesNumbertotalBytesNumber
Download size in bytes. If the size is unknown, it returns 0.speedNumber
Download speed in bytes per second.
Download Updated
Fires periodically when there is an update to the download (ex. progress update, paused/resumed events, download failed, etc.)
window.deskifier.filesystem.onDownloadUpdated((downloadData) => {})
Arguments
idString
The download ID.savePathString
Where the download is being saved to.fileNameString
The name of the file being downloaded.mimeTypeString
The type of file being downloaded.stateString
Can beprogressing,completed,cancelled,pausedorinterrupted.percentCompletedNumber
Percent out of 100transferredBytesNumbertotalBytesNumber
Download size in bytes. If the size is unknown, it returns 0.speedNumber
Download speed in bytes per second.
Example
<pre class="language-javascript"><code class="lang-javascript"><strong>window.deskifier.filesystem.onDownloadUpdated((downloadData) => { </strong> console.log(downloadData); }); <strong> </strong>/* { id: '6a191b', savePath: "C:\Users\Example\Downloads\renamedExample.zip", fileName: "example.zip", mimeType: "application/zip" state: 'progressing', percentCompleted: 27.5, transferredBytes: 28835737, totalBytes: 104857600, speed: 524288 } */ </code></pre>
Download Completed
Fires only when a download successfully completes.
window.deskifier.filesystem.onDownloadCompleted((downloadData) => {})
Arguments
idString
The download ID.
Example
<pre class="language-javascript"><code class="lang-javascript">window.deskifier.filesystem.onDownloadCompleted((downloadData) => { console.log(downloadData); }); <strong> </strong>/* { id: 'foobar' } */ </code></pre>
Download Canceled
Fires when a download fails or is canceled.
window.deskifier.filesystem.onDownloadCanceled((downloadData) => {})
Arguments
idString
The download ID.stateString
Can becancelledorfailed.messageString
The error message, if any.
Example
<pre class="language-javascript"><code class="lang-javascript">window.deskifier.filesystem.onDownloadCanceled((downloadData) => { console.log(downloadData); }); <strong> </strong>/* { id: 'foobar', state: 'cancelled', message: 'Download was cancelled' } */ </code></pre>
Path Update
Fires when a watched path is updated.
window.deskifier.filesystem.onPathUpdate((data) => {})
Arguments
watchIdString
The ID of the observer.pathString
The path being watched.eventTypeString
Can berenameorchange.renameis emitted whenever a filename appears or disappears in the directory.filenameString
The filename that changed. Can sometimes benull.
Example
<pre class="language-javascript"><code class="lang-javascript">window.deskifier.filesystem.onPathUpdate((data) => { console.log(data); }); <strong> </strong>/* { watchId: 'foobar', path: 'C:\Users\Example\Desktop', eventType: 'rename', filename: 'example.png' } */ </code></pre>