Docs
ServoyCloudSupportSamplesOpen SourceCommunity
  • Home
  • GUIDES
    • Platform Overview
    • Get Servoy
    • Get Started
      • Chapter 0
      • Chapter 1
      • Chapter 2
      • Chapter 3
      • Chapter 4
      • Chapter 5
    • Get Help
      • SuLA Instructions
      • SuLA Terms
    • Develop
      • Application Design
        • Forms
          • Layout Management
            • Simple Layout
            • Fully Responsive
              • Bootstrap 12-Grid
              • Flexbox
              • Custom Div
              • Collapsible Container
              • Simple Collapsible
              • Center Container
              • Inline Group Container
            • Abstract Form
          • Form Containers
            • Form Container
            • Tab Panel
            • Split Pane
            • Collapse
            • Accordion Panel
            • Form Component
            • List Form Component
          • Form Inheritance
          • Form Components
        • UI Components
          • Buttons and Text
            • Badge
            • Button
            • Data Label
            • Dropdown
            • Image
            • Label
          • Grids
            • Data Grid
            • Power Grid
            • Table
          • Input Controls
            • Calendar
            • Calendar Inline
            • Checkbox
            • Choice Group
            • Combobox
            • Group Buttons
            • Html Area
            • Input Group
            • Rating
            • Slider
            • Switch
            • Spinner
            • TextArea
            • Textbox
            • TextBoxGroup
            • Type Ahead
            • select2tokenizer
          • Media
            • Carousel
            • Embedded YouTube
            • File upload
            • Image label
            • Lightbox Gallery
            • MultiFile Upload
            • PDF JS Viewer
            • PDF Viewer
          • Mobile
            • Native Data List
            • Native Select
          • Navigation
            • Breadcrumbs
            • Navbar
            • sidenav
          • Visualization
            • DBTreeview
            • Progress Bar
            • Treeview
            • ChartJS
              • Data Labels Plugin
              • Funnel Chart
              • OutLabels Plugin
              • TreeMap
          • Specialized Components
            • Smart Document Editor
            • Servoy PDF Viewer
            • Fullcalendar Component
              • Fullcalendar
              • Fullcalendar Events
              • Migrating calendar from Smart and Web client to NG client
            • Fullcalendar Component 2
            • Canvas
            • Google Charts
            • Google Maps
            • svySignature
            • svywebcam
        • Styling and Themes
          • Default Theme Properties
          • CSS / LESS
          • Component Variants
          • Font Icons
        • Data Modeling
          • Databases
            • Tables
              • Columns
              • Calculations
              • Aggregations
              • Methods
              • Events / Triggers
              • Table security
            • Views
            • Procedures
          • Relations
          • Value Lists
          • Menus
          • In-Memory Databases
          • View Datasource
        • Modular Design
      • Programming Guide
        • Scripting the UI
          • Scripting Forms
          • Interacting with Components
          • Navigation
          • Windows, Dialogs and Popups
          • Events Manager
        • Working with Data
          • Concepts
          • Loading
          • Sorting
          • Iterating
          • Searching
            • Find mode
            • Query Builder
            • SQL String
          • Filtering
          • Editing
          • Validation
        • Automation and Scheduling
          • Batch Processor
          • Headless API
          • Scheduler API
        • Creating REST APIs
        • Consuming Webservices
        • Working with Files
          • File Plugin Basics
          • Images
          • Excel
          • PDF
          • JSON
        • Browser Utilities
          • Notifications
            • Web Notifications (Toastr)
            • Web Notifications (Native)
            • Block UI
          • Session Management
          • Keyboard Utilities
          • NG Utils
        • Sending and Receiving Email
        • Servoy Jasper Reports
          • Input Type
          • Display Mode
          • Output format
          • Jaspe Reports Viewer
        • Extensions
          • Modules
            • svyPhonegap
              • First Use Guide
              • Barcode Scanner
              • Browser
              • Camera
              • File
              • Fingerprint
              • Location
              • Network Interface
              • Phonegap
              • Printer
              • Push Notifications
            • svyAPI
              • Getting Started
            • svyLookup
              • Custom Templates
              • API Documentation
              • svyLookup v1
                • API Documentation v1.0.0
                • Base Form svyLookupTable v1.0.0
                • Base Form AbstractLookup v1.0.0
            • svyNavigation
              • API Documentation
                • API svyNavigation
                • API svyNavigationHistory
                • API svyNavigationUX
            • svyPopupFilter
              • Simple Filter Pickers
              • Custom Templates
              • API Documentation
                • API svyToolbarFilter
                • API svyPopupFilter
              • API Documentation v1
                • API svyToolbarFilter v1
                • API svyPopupFilter v1
            • svySearch
            • svySecurity
              • Overview
              • Token-based Auth and SSO (NEW!)
              • API Documentation
              • Getting Started
              • Tenant replication
              • Security Management Console
                • Classic Security Management Console
              • svySecurityUX
              • svyProperties
              • API Doc svyProperties
            • svyUtils
              • Log Manager
              • Log Manager Appenders
              • Smart Doc Editor Utils
              • Custom Dialogs
              • Excel Utils
                • Full API Reference
              • Crypto Utils
      • Security
        • Authentication
        • Permissions
          • UI Permissions
          • Data Permissions
          • Runtime Permissions
        • Audit Logging
        • OAuth
        • JWT
      • Multi-Language Support
      • Mobile Development
        • Getting Started
        • Mobile Design
        • Native Mobile Integrations
        • Building a Native Binary for the App Store
      • Native Desktop Development
        • NGDesktop UI plugin
        • NGDesktop Utils
        • NGDesktop File Plugin
    • Deploy
      • WAR Deployment
      • Docker Deployment
      • Server Configuration
        • Server Settings
        • Server Plugins
        • Database Servers
          • Locks
          • Transactions
          • Oracle
          • SQLServer
        • Client Sessions
        • Batch Processors
        • License Management
        • Monitoring
          • Server Log
          • Browser Console Log
          • Websocket Log
          • Query Performance
          • Client Performance
          • Client Event Tracing
          • Monitoring Servoy with JMX
      • NGClient deployment
      • Troubleshooting
      • Other Topics
        • Security: Cross-site Scripting
        • Running in an iFrame
    • Extend
    • Contribute
  • Reference
    • Servoy Core
      • Object Model
        • Database Server
          • Table
            • Column
            • Calculation
            • Method
            • Aggregation
          • View
          • Procedure
        • Solution
          • Form
          • Form Component
          • Relation
          • Relation Item
          • Table Node
          • Value List
          • Menu
          • Menu item
          • In-Memory Data Source
          • View Foundset Data Source
          • Variable
          • Column Info
          • Media
          • Layout Container
          • Method
        • i18n Message Key
      • Developer API
        • Globals
        • Forms
          • RuntimeForm
            • controller
            • containers
              • RuntimeContainer
            • elements
              • Component
              • RuntimeAccordionPanel
              • RuntimeBean
              • RuntimeButton
              • RuntimeCalendar
              • RuntimeCheck
              • RuntimeCombobox
              • RuntimeComponent
              • RuntimeDataButton
              • RuntimeDataLabel
              • RuntimeGroup
              • RuntimeHtmlArea
              • RuntimeImageMedia
              • RuntimeInsetList
              • RuntimeLabel
              • RuntimeListBox
              • RuntimePassword
              • RuntimePortal
              • RuntimeRadio
              • RuntimeChecks
              • RuntimeRadios
              • RuntimeRectangle
              • RuntimeRtfArea
              • RuntimeSpinner
              • RuntimeSplitPane
              • RuntimeTabPanel
              • RuntimeTextArea
              • RuntimeTextField
              • RuntimeWebComponent
        • JS Lib
          • Array
          • BigInt
          • Boolean
          • Date
          • Function
          • IterableValue
          • Iterator
          • JSON
          • Map
          • Set
          • Math
          • Namespace
          • Number
          • Object
          • Promise
          • QName
          • RegExp
          • Special Operators
          • Statements
          • String
          • XML
          • XMLList
        • Application
          • APPLICATION_TYPES
          • CLIENTDESIGN
          • DRAGNDROP
          • ELEMENT_TYPES
          • LOGGINGLEVEL
          • NGCONSTANTS
          • UICONSTANTS
          • CSSPosition
          • JSDimension
          • JSDNDEvent
          • JSEvent
          • JSLogger
          • JSLogBuilder
          • JSPoint
          • JSUpload
          • JSWindow
          • JSBounds
          • Renderable
          • UUID
        • SolutionModel
          • ALIGNMENT
          • ANCHOR
          • BEVELTYPE
          • CURSOR
          • DEFAULTS
          • FONTSTYLE
          • MEDIAOPTION
          • PAGEORIENTATION
          • PRINTSLIDING
          • SCROLLBAR
          • TITLEJUSTIFICATION
          • TITLEPOSITION
          • UNITS
          • JSBean
          • JSButton
          • JSCalculation
          • JSComponent
          • JSDataSourceNode
          • JSField
          • JSForm
          • JSLabel
          • JSMedia
          • JSMethod
          • JSPart
          • JSPortal
          • JSRelation
          • JSRelationItem
          • JSStyle
          • JSTab
          • JSTabPanel
          • JSValueList
          • JSVariable
          • JSTitle
          • JSChecks
          • JSCombobox
          • JSHeader
          • JSInsetList
          • JSList
          • JSPassword
          • JSRadios
          • JSText
          • JSTextArea
          • JSWebComponent
          • JSLayoutContainer
        • Database Manager
          • QUERY_COLUMN_TYPES
          • SQL_ACTION_TYPES
          • JSColumn
          • JSDataSet
          • JSBaseRecord
          • JSBaseSqlRecord
          • JSBaseFoundset
          • JSBaseSQLFoundset
          • JSFoundSet
          • JSFoundSetUpdater
          • JSRecord
          • JSRecordMarker
          • JSRecordMarkers
          • JSTable
          • JSTableFilter
          • MenuFoundSet
          • MenuItemRecord
          • QBAggregate
          • QBAggregates
          • QBCase
          • QBCaseWhen
          • QBColumn
          • QBColumns
          • QBCondition
          • QBFunction
          • QBFunctions
          • QBGroupBy
          • QBJoin
          • QBJoins
          • QBLogicalCondition
          • QBParameter
          • QBParameters
          • QBPart
          • QBResult
          • QBSearchedCaseExpression
          • QBSelect
          • QBSort
          • QBSorts
          • QBTableClause
          • QBWhereCondition
          • ViewFoundSet
          • ViewRecord
        • Events Manager
          • EVENTS_AGGREGATION_TYPES
          • EventType
        • Menus
          • JSMenu
          • JSMenuItem
        • JSMenuDatasource
        • Utils
        • Client Utils
          • JSBlobLoaderBuilder
        • History
        • Security
        • i18n
        • ServoyException
          • DataException
        • JSUnit
        • Datasources
          • DBDataSource
          • DBDataSourceServer
          • JSConnectionDefinition
          • JSDataSource
          • MemDataSource
          • MenuDataSource
          • SPDataSource
          • SPDataSourceServer
          • ViewDataSource
        • JSViewDatasource
        • servoyDeveloper
        • enum
    • Extensions
      • UI Components
        • Buttons and Text
          • Badge
          • Button
          • Data Label
          • Drop Down
          • Image
          • Label
        • Form Containers
          • Accordion Panel
          • Collapse
          • Form Container
          • Form Component Container
          • List Form Component
          • Default Loading Indicator
          • Error Bean
          • Portal
          • Responsive Container
          • Servoy Default Navigator
          • Slider
          • Split Pane
          • TabPanel
        • Grids
          • Data Grid
          • Power Grid
          • Table
        • Input Controls
          • Calendar
          • Calendar Inline
          • Checkbox
          • Choice Group
          • Combobox
          • Floatinglabel Calendar
          • Floatinglabel Combobox
          • Floatinglabel Textarea
          • Floatinglabel Textbox
          • Floatinglabel Type Ahead
          • Group Buttons
          • Html Area
          • Input Group
          • Rating
          • Select2tokenizer
          • Slider
          • Spinner
          • Switch
          • TextArea
          • TextBox
          • TextBox Group
          • Type Ahead
        • Media
          • Carousel
          • Embedded YouTube
          • File upload
          • Image label
          • Lightbox Gallery
          • MultiFile Upload
          • PDF JS Viewer
          • PDF Viewer
        • Mobile
          • Native Data List
          • Native Select
        • Navigation
          • Breadcrumbs
          • Navbar
          • sidenav
        • SmartDocEditor
          • Smart Document Editor
        • Visualization
          • Canvas
          • Chart
          • Custom List
          • DBTreeview
          • Foundset List
          • Fullcalendar
          • Gauge
          • Google Maps
          • Kanban
          • Progress Bar
          • Treeview
      • Server Plugins
        • amortization
          • AmortizationCalculation
          • Polynomial
        • clientmanager
          • Broadcaster
          • JSClientInformation (cm)
        • excelxport
        • file
          • JSFile
          • JSProgressMonitor
        • headlessclient
          • JSClient
        • http
          • HTTP_STATUS
          • Cookie
          • DeleteRequest
          • GetRequest
          • HeadRequest
          • HttpClient
          • HttpClientConfig
          • OptionsRequest
          • PostRequest
          • PutRequest
          • Response
          • TraceRequest
          • PatchRequest
          • JSFileUpload
        • images
          • JSImage
        • jwt
          • Algorithm
          • Builder
          • JWTClaims
        • mail
          • Attachment
          • MailMessage
        • maintenance
          • JSClientInformation
          • JSColumnObject
          • JSServer
          • JSTableObject
        • mobileservice
          • OfflineDataDescription
        • oauth
          • ClientAuthentication
          • CustomApiBuilder
          • OAuthProviders
          • OAuthRequest
          • OAuthResponse
          • OAuthResponseBinary
          • OAuthResponseJSON
          • OAuthResponseText
          • OAuthService
          • OAuthServiceBuilder
          • OAuthTokenExtractors
          • RequestType
        • pdf_output
        • rawSQL
        • RestWs plugin
        • rest_ws
          • WsContents
          • WsCookie
          • WsRequest
          • WsResponse
        • scheduler
        • serialize
        • textxport
          • DataProviderExport
          • TabExporter
        • udp
          • JSPacket
        • XmlReader
          • XmlNode
      • Browser Plugins
        • Block UI
        • Block UI (ref)
        • Dialogs Plugin
        • Idle
        • Idle (ref)
        • Key Listener
        • Key Listener (ref)
        • NGDesktop File
        • NGDesktop File (ref)
        • NGDesktop UI (ref)
        • NGDesktop Utils (ref)
        • NG Utils (ref)
        • Office Javascript API for Servoy
        • Phonegap
        • Web Notifications (Native)
        • Web Notifications (Toastr)
        • Window Plugin
        • Font Awesome
      • Modules
        • Smart Doc Editor Utils
        • svyAPI
          • Getting Started
        • svyLookup
          • Custom Templates
          • API Documentation
          • svyLookup v1
            • API Documentation v1.0.0
            • Base Form svyLookupTable v1.0.0
            • Base Form AbstractLookup v1.0.0
        • svyLookupExample
        • svyNavigation
          • API Documentation
            • API svyNavigation
            • API svyNavigationHistory
            • API svyNavigationUX
        • svyNavigationUX
        • svyNavigationUXSample
        • svyPopupFilter
          • Simple Filter Pickers
          • Custom Templates
          • API Documentation
            • API svyToolbarFilter
            • API svyPopupFilter
          • API Documentation v1
            • API svyToolbarFilter v1
            • API svyPopupFilter v1
        • svyProperties
        • svySearch
        • svySecurity
          • Overview
          • Token-based Auth and SSO (NEW!)
          • API Documentation
          • Getting Started
          • Tenant replication
          • Security Management Console
            • Classic Security Management Console
          • svySecurityUX
          • svyProperties
          • API Doc svyProperties
        • svySecurityConsole
        • svySecurityUX
        • svyUtils
          • Log Manager
          • Log Manager Appenders
          • Smart Doc Editor Utils
          • Custom Dialogs
          • Excel Utils
          • Full API Reference
          • Crypto Utils
        • svyUtils$Excel
        • svyUtils$NGClient
        • svyUtils$customDialogs
        • svyUtils$logManagerAppenders
        • svyUtils$tableGrid
      • Layout
        • Boostrap 12grid layout
          • Collapsible Container
          • Simple Collapsible
          • Center Container
          • Inline Group Container
          • Flexbox Layout
      • Solutions
        • Sample Application
          • Tutorial Part 1
          • Tutorial Part 2
      • Packages
        • UI Component Packages
          • Advanced Renderers
          • Bootstrap Components
          • Bootstrap Extra Components
          • Canvas
          • Chart JS
          • Fullcalendar Component
          • googlemaps
          • kanban
          • Servoy Core
          • Servoy Extra Components
          • Servoy NG-Grids
          • Servoy PDF Viewer
          • smartDocumentEditor
        • Browser Plugin Packages
          • Block UI
          • Core NG only Services
          • Key Listener
          • NGDesktop File
          • NGDesktop UI
          • NGDesktop Utils
          • Web Notifications
          • Idle Web Service
    • Servoy Developer
      • Menu
        • File
        • Edit
        • Source
        • Refactor
        • Navigate
        • Search
        • Project
        • Actions
        • Run
        • Window
        • Help
      • Toolbar
      • Solution Explorer
        • Resources
          • Database Servers
            • Database Server
              • Procedures
              • Tables
              • Views
          • Security
          • i18n
        • All Solutions
          • Solution
          • Active Solution
            • Scopes
              • Scope
                • Variables
            • Forms
              • Working Set
              • Form
                • Controller
                • Variables
                • Elements
                • Relations
            • Form Components
              • Form Component
            • Relations
              • Relation
            • ValueLists
              • ValueList
            • Menus
              • Menu
                • MenuItem
            • Media
              • Folder
              • File
            • DataSources
              • In Memory DataSources
                • In Memory DataSource
              • View Foundsets DataSources
                • View Foundset DataSources
            • Servoy Packages
              • Package
            • Modules
              • Module
        • Solution Explorer Contextual List
      • Views
        • Command Console
        • Console
        • Problems
        • Tasks
        • Bookmarks
        • Search
        • Form Hierarchy
        • Help
        • JUnit
        • Outline
        • Profiler
        • Properties
        • Project Explorer
        • Call Hierarchy
      • Editors and Wizards
        • Property configurator for columns
        • Relation Editor
        • Text Format Editor
        • Date Format Editor
        • Number Format Editor
        • Database Synchronization Wizard
        • Security Editor
        • SQL Editor
        • i18n Editor
        • File Import Wizard
        • File Export Wizard
        • WAR Export Wizard
        • NGDesktop Export Wizard
        • Table Editor
        • Metadata Synchronization Wizard
        • Database Server Connection Editor
        • Text Property Editor
        • Valuelist Editor
        • Form Editor
          • Parts of the Form Editor
          • Designing a Form
          • Layout Tools
          • Using Containers
          • Creating and Using Forms
          • Using Servoy Beans
          • Using Shapes
          • Form Editor Subtabs
          • [Tips and Shortcuts][reference/servoy-developer/object-editors/form-editor-tips_and_shortcuts.md]
          • Editong a Responsive LayoutForm
          • CSS Positioning
        • Form Hierarchy
        • Component Properties Editor
        • Variable Editor
        • Method Selection Wizard
        • New Solution Wizard
        • Application Event Types Editor
        • New Form Wizard
        • Form Dataproviders Configurator
        • Servoy Resource Locator
        • Datasource Selection Wizard
        • Sorting Fields Wizard
        • Scripting Editor
          • Getting Started-Overview of Script Editor
          • Code Writing Features
          • Code Navigation
          • Code Rewriting Tools
          • Refactoring
          • Code Formatting
          • Script Editor Tips and Shortcuts
          • Unit Tests
        • Theme Editor
          • General Properties
          • Sidenav Properties
          • Navbar Properties
          • Tabs Properties
          • Windows Properties
          • Dialogs Properties
          • Tables Properties
          • Breadcrumb specific style Properties
          • Brand colors Properties
          • Validations Properties
          • Margins and Padding Properties
        • Editor Selection
        • Run Configurations
        • Debug Configurations
        • Externalize Strings Wizard
        • Font Chooser Wizard
        • Color Chooser Wizard
        • Project Properties Configurator
        • Move Wizard
        • External Tools Configurations
        • About Servoy Developer
        • Servoy Developer Installation Details
        • Eclipse Marketplace Wizard
        • Install Available Software Wizard
        • Cheat Sheet Selection Wizard
        • Servoy Developer Help Wizard
        • Switch to Editor Wizard
        • Find Actions Wizard
        • Customize Perspective Configurator
        • Quick Search Wizard
        • Search Wizard
        • Encoding Wizard
        • Task Wizard
        • Find - Replace Wizard
        • Properties Editor
        • New Project Wizard
        • New Method Wizard
        • New Menu Wizard
          • New MenuItem Wizard
        • Menu Editor
        • ServoyMenu Selection Wizard
        • JSMenu compatible component selector
        • Permissions Configuration Dialog
      • Project File Structure
        • Servoy Installation Directory
          • servoy.properties
        • Workspace Folder
          • Resources Directory
            • Database Information (.dbi) Files
          • Solution Folder
      • Package Manager
      • Preferences
      • Property Types for components / services
      • Debugger
        • Debug Explorer
        • Breakpoints
          • Breakpoint Properties
        • Variables
        • Expressions
        • Interactive Console
    • Application Server
    • Servoy Cloud
      • Cloud Control Center
        • Home
          • Setup Namespace
          • User profile
            • My Profile
            • Support
        • Download IDE
        • Application Overview
          • Applications
            • Pipelines
              • Jobs
                • Packages
                  • Commits
                  • Artifacts
                  • Configuration
                  • Quality reports
                  • Build markers
                • Job Configuration
                  • Build and Deploy or Build
                  • Mobile
                  • Desktop
            • Environments
              • Metrics
                • Users
                • Databases
                  • Metrics
                • System Health
                • Log Activity
                • App performance
                • Query performance
              • Cloud reporting
            • Security
              • Permissions
              • Tenants
            • Reports
            • Security Login Designer
              • Single Sign-On
                • Sign in with Google
                • Sign in with Microsoft
          • Code Repositories
        • Project Management
          • Tickets
          • Backlog
          • Active Sprints
        • User Management
          • Users
          • Roles
        • Administration
          • Security
            • ServoyCloud Roles
          • Credentials
          • Settings
        • Add-Ons
      • Database Backup
      • E2E Cypress Testing
        • Using Cypress
      • On-Premise Deployment
      • Privacy policy (ServoyAI)
      • FAQ
      • Migrate to Servoy Cloud
    • Extensions Developement
      • Component and Services
        • Component Development
        • Service Development
        • Tools and Dev Tips to use for Component/Service developement
        • Manifest (.mf file)
        • Specification (.spec file)
          • Property Types
            • Array property types
            • Custom object property types
            • Findmode property type
            • Foundset property type
            • Tags
        • Directives And Filters
          • Sablotabsequence
        • Console (serverside)
        • ServoyApi (serverside)
      • Serverside Plugins
        • Data Convertors and Validators
        • UI Convertors
  • Release notes
    • Release notes
      • 2025.03
      • 2024.03 (LTS)
      • 2023.03 (LTS)
      • 2025.03 (Servoy Cloud)
      • 2024.12
      • 2024.12 (Servoy Cloud)
      • 2024.09
      • 2024.09 (Servoy Cloud)
      • 2024.06
      • 2024.06 (Servoy Cloud)
      • 2024.03 (Servoy Cloud)
      • 2023.12
      • 2023.12 (Servoy Cloud)
      • 2023.09
      • 2023.09 (Servoy Cloud)
      • 2023.06
      • 2022.03 (LTS)
      • 2022.12 What's new
      • 2022.12
      • 2022.09 What's new
      • 2022.09
      • 2022.06 What's new
      • 2022.06
      • 2021.03.3 (LTS)
Powered by GitBook
On this page
  • Overview
  • Getting File Info
  • Create File
  • Working with Text Files
  • Writing Text Files
  • Reading Text Files
  • Working with Binary Files
  • Writing Binary Files
  • Reading Binary Files
  • Working with XML Files
  • Writing XML Files
  • Downloading Files / Opening a File in the Browser
  • Uploading Files
  • File System Operations (Server-side)
  • Listing Files
  • Moving Files
  • Copying Files
  • Working with Temp Files
  • Tracking Files

Was this helpful?

  1. GUIDES
  2. Develop
  3. Programming Guide
  4. Working with Files

File Plugin Basics

File Plugin Basics Guide

PreviousWorking with FilesNextImages

Last updated 6 months ago

Was this helpful?

Overview

The File Plugin in Servoy provides server-side access to file system operations when working with browser clients and can also be used on NGDesktop for client-side file access. With the plugin, developers can handle file operations such as retrieving metadata, reading/writing text or binary data, uploading and downloading files, and performing file system operations like moving, copying, and tracking files.

For NGDesktop applications, where client-side file access is required, you can use specific features that provide access to the local file system directly. You can find relevant documentation on NGDesktop file.

More information about File Plugin can be found . More information about JSFile can be found .

Getting File Info

You can retrieve various file metadata such as the file path, size, and last modified time.

Code Example: Get File Metadata

            var f = plugins.file.convertToJSFile('./my-file.txt');
			if (f && f.exists()) {
				application.output('is absolute: ' + f.isAbsolute());
				application.output('is dir: ' + f.isDirectory());
				application.output('is file: ' + f.isFile());
				application.output('is hidden: ' + f.isHidden());
				application.output('can read: ' + f.canRead());
				application.output('can write: ' + f.canWrite());
				application.output('last modified: ' + f.lastModified());
				application.output('name: ' + f.getName());
				application.output('path: ' + f.getPath());
				application.output('absolute path: ' + f.getAbsolutePath());
				application.output('content type: ' + f.getContentType());
				application.output('size: ' + f.size());

                application.output('modification date: ' + plugins.file.getModificationDate(f)); 

			} else {
				application.output('File/folder not found.');
			}

Create File

Here is a simple example that creates a file helloworld.txt in the user folder of user "servoy" in Windows:

var f = plugins.file.createFile("C:\\users\\servoy\\helloworld.txt");
f.createNewFile();

Back slash in windows file paths: In the example above the path C:\users\servoy\helloworld.txt is written as C:\\users\\servoy\\helloworld.txt (with double back slashes). This is done because the \ is the escape character in javascript strings.

Another option is to use / instead, this will work just as well:

var f = plugins.file.createFile("C:/users/servoy/helloworld.txt");
f.createNewFile();

Here an example to create a file in the home directory of user "servoy" in Ubuntu:

var f = plugins.file.createFile("/home/servoy/helloworld.txt");
f.createNewFile();

To do the same on a Mac:

var f = plugins.file.createFile("/Users/servoy/helloworld.txt");
f.createNewFile();

Here is a sample that does the same as the previous examples, but it works on all the operating systems above:

var f = plugins.file.createFile(plugins.file.getDesktopFolder() + "/helloworld.txt");
f.createNewFile();

Working with Text Files

Writing Text Files

Code Example: Writing Text to a File

var file_text = "Hello world!";
var f = plugins.file.convertToJSFile(plugins.file.getDesktopFolder() + "/helloworld.txt");
plugins.file.writeTXTFile(f, file_text);

Reading Text Files

Code Example: Reading Text from a File

var file_text = plugins.file.readTXTFile(plugins.file.getDesktopFolder() + "/helloworld.txt");
var file_text = plugins.file.readTXTFile(plugins.file.getDesktopFolder() + "/helloworld.txt", "ISO8859_1");
var file_text = plugins.file.readTXTFile(); 

Memory Considerations When working with large text files, it's important to consider memory usage, as reading large files entirely into memory could exhaust available resources. For larger files, consider processing them line by line.

When using readTXTFile, the entire text is written to the memory. With big text files this might be a problem, because they take a lot of memory, maybe even more than available. Because of this problem, using readTXTFile is not the best option if to read huge files. In that case it is better to use some inline java code to read the file line by line using a buffered reader. See this example:

var file_Name = plugins.file.showFileOpenDialog();
var f = new Packages.java.io.File(file_Name);
var file_reader = new Packages.java.io.BufferedReader(new Packages.java.io.FileReader(f));
var text;
while ((text = file_reader.readLine()) != null) {
application.output(text);
// Do other stuff with the text here
}
//close the reader
file_reader.close();

Working with Binary Files

Writing Binary Files

Code Example: Writing Binary Data

var file_bytes = photo; // photo is a blob column from the database
var f = plugins.file.convertToJSFile(plugins.file.getDesktopFolder() + "/photo.jpg");

// Writing binary data to the file
plugins.file.writeFile(f, file_bytes);

Reading Binary Files

Code Example: Reading Binary Data

var file_bytes = plugins.file.readFile(plugins.file.getDesktopFolder() + "/helloworld.jpg");

If only a part of the file has to be read, the number of bytes can be specified using the second parameter. For example if 1kB should be read:

var file_bytes = plugins.file.readFile(plugins.file.getDesktopFolder() + "/helloworld.jpg", 1024);
var file_bytes = plugins.file.readFile();

Memory Considerations When reading or writing large binary files, you must manage memory carefully to avoid heap space issues. Consider breaking large files into smaller chunks and processing them in parts.

Working with XML Files

Writing XML Files

Code Example: Writing XML Data to a File

var xml_content = <hello>world</hello>;
var f = plugins.file.convertToJSFile(plugins.file.getDesktopFolder() + "/helloworld.xml");

// Writing XML data to the file
plugins.file.writeXMLFile(f, xml_content);

Downloading Files / Opening a File in the Browser

Code Example: Downloading a File

function onDownload(event) {
	var f = plugins.file.convertToJSFile("helloworld.txt")
	download_file(f)
}

function download_file(file)
{
	plugins.file.openFile(file);
}

Uploading Files

Code Example: Uploading Files

 function openFile(event) {
	plugins.file.showFileOpenDialog(onOpen)
}

function onOpen(files){
	plugins.file.openFile(files[0]);
	application.output(files[0])
}

Servoy also provides dedicated UI components for file uploading, allowing more customization and flexibility in handling user uploads. These components offer features such as multiple file selection and additional styling options, making them ideal for applications with more complex file upload requirements.

File System Operations (Server-side)

Listing Files

Code Example: Listing Files in a Directory

var files = plugins.file.getFolderContents('myFolder', '.txt');
		for (var i = 0; i < files.length; i++)
			application.output(files[i].getAbsolutePath());

Moving Files

Code Example: Moving Files by Name

if (!plugins.file.moveFile('home.txt', 'home.txt.new')) {
    application.output('File move failed.');
} else {
    application.output('File moved successfully.');
}

Code Example: Moving Files with JSFile Instances

var sourceFile = plugins.file.convertToJSFile('home.txt.new');
var destinationFile = plugins.file.convertToJSFile('home.txt');

if (!plugins.file.moveFile(sourceFile, destinationFile)) {
    application.output('File move back failed.');
} else {
    application.output('File moved back successfully.');
}

Copying Files

Code Examples: Copying Files Based on File Names: You can copy files using their file paths as string values.

if (!plugins.file.copyFile("home.txt", "home.txt.copy")) {
    application.output("Copy failed.");
} else {
    application.output("Copy succeeded.");
}

Copying Files Based on JSFile Instances: Alternatively, you can copy files by first creating JSFile objects.

var sourceFile = plugins.file.createFile("home.txt");
var destinationFile = plugins.file.createFile("home.txt.copy2");

if (!plugins.file.copyFile(sourceFile, destinationFile)) {
    application.output("Copy failed.");
} else {
    application.output("Copy succeeded.");
}

Working with Temp Files

Code Example:

var tempFile = plugins.file.createTempFile("helloworld", ".txt");

After executing this code, there will be a new (empty) file in the temp directory with a name like this: helloworld1571360175321712533.txt. The filename will be unique because of the number that is added in the middle.

Tracking Files

Usage Scenario: If your application creates temporary files (such as log files, data exports, or reports) that are needed during the session but not afterward, this method allows you to automatically delete these files when the solution closes.

Code Example:

var file = plugins.file.createFile("newfile.txt");

// Write some data to the file
plugins.file.writeTXTFile(file, "Temporary data for session.");

// Track the file for deletion when the client solution is closed
plugins.file.trackFileForDeletion(file);

To create a file, there should be a first. Creating JSFiles can be done using the function . On a JSFile there is the function to actually create the file on disk.

OS-independent path: As can be seen in the examples above, it is not a good practice to use hardcoded paths in the code, because they don't work on every OS. It is better to use a more general approach. The file plugin has several functions to help with that: and .

The method is used to write content to files in text format. You can specify the file where the text will be written, the text content itself, and optionally the encoding format. By default, the system uses the operating system's default encoding, but you can override this by specifying a different encoding if needed.

Reading from a text file can be done using the method.

Optionally the charset can be specified in the second parameter, if left out it will take the OS default (For a list of possible charsets, look ):

If the user should choose which file to read, can be called without parameters, then a file choose dialog will open:

To write binary data to a file, you can use method by passing a byte array. The plugins.file.writeFile method allows you to write binary data (such as images, PDFs, or any other file in binary format) to a file. This is useful when working with binary data from databases or other sources that need to be saved as files on the server or client-side.

You can read binary files with the method. The plugins.file.readFile method allows you to read the contents of binary files, such as images, PDFs, or any other file that contains non-text data. This method returns the binary data as a byte array, which can then be processed or stored in a database.

If the user should choose which file to read, can be called without parameters, then a file choose dialog will open:

In Servoy, you can write XML files using the method. This allows you to store structured data in XML format, which is commonly used for configurations, data interchange, or documents.

Servoy allows you to trigger file downloads or open files directly in the browser. This can be done using method.

File uploads in Servoy are handled using the method. Uploaded files can be processed server-side.

Default Upload Location The servoy.FileServerService.defaultFolder property in Server Plugins section of determines where files are uploaded by default on the server. You can change this property to suit your application's needs.

: This component allows users to upload individual files with a user-friendly interface. It can be customized to match the application's design and offers events like file selection and upload progress tracking.

: This component enables users to upload multiple files at once, providing a streamlined experience for applications that require bulk file uploads. It supports multiple file selection, drag-and-drop functionality, and file size validations.

To list files in a directory, use method. The plugins.file.getFolderContents method retrieves an array of JSFile instances representing the files and directories within a specified folder. This method is useful for obtaining the list of files from a directory, and it supports various filters to narrow down the content based on file names, file types, visibility, and lock status.

You can move files using the method. The plugins.file.moveFile method allows you to move files from one location to another. You can move files based on their file names (as strings) or by using JSFile instances. The method returns true if the move is successful and false if any error occurs during the process.

The method allows you to copy files from one location to another. You can use this method to duplicate files based on file names or JSFile instances. The method returns true if the copy operation is successful, and false if any error occurs during the process.

Servoy provides the ability to create temporary files that are automatically managed and removed when the client session ends. These temp files are useful for handling data that is only needed during the session and should not persist after the solution is closed. Temp files will be created in the default temporary-file directory, using the given prefix and suffix to generate its name. Temporary files can be created using method.

The method in Servoy ensures that a file is automatically deleted when the client’s solution is closed. This method is particularly useful for managing temporary files that should only persist during the session and should be cleaned up afterward, whether they are local or remote files.

here
File Upload Component
MultiFile Upload Component
Servoy Admin Page
here
JSFile
JSFile.createNewFile
here
here
plugins.file.createFile
plugins.file.getDesktopFolder
plugins.file.getHomeFolder
plugins.file.writeTXTFile
plugins.file.readTXTFile
plugins.file.readTXTFile
plugins.file.writeFile
plugins.file.readFile
plugins.file.readFile
plugins.file.writeXMLFile
plugins.file.openFile
plugins.file.showFileOpenDialog
plugins.file.getFolderContents
plugins.file.moveFile
plugins.file.copyFile
plugins.file.createTempFile
plugins.file.trackFileForDeletion