["File System API"]  # File System API ArOZ Online File System is the core of the whole cloud software system as it provide all the fundemental functions that is required for all WebApp modules. In simple words, the file system of ArOZ Online System consists of the following elements - File Explorer - File Operation Function Group - File System Asynchronize Function Group (Go-lang written, included as a pre-compiled binary file) - File System Synchronize Function Group (PHP written, compatibility mode only.) - File Selector - File Explorer Shortcuts - File Extension Default Opener - New Item Menu In this page, the functions and the API of the elements above will be introduced.  ## File Explorer UI The File Explorer provide basic file and folder navigation functions for the ArOZ Online System. The File Explorer UI provides the interface for users to interact with on VDI Mode or PWA Mode. See Advanced Documentation in Quick Start Guide for more information of the UI.  ## File Operation Function Group The ArOZ Online System consists of two set of file operation function groups. They provide interface for performing the following file operations - Copy & Paste - Move - Compress & Decompress - UM-Filename to UTF-8 Filename Conversion The following functions are not included in the file operation function groups. - Rename - Delete - Open / Open With - Download ### File System Asynchronize Function Group The Asynchronize function group is a set of go-lang written programs that provide asynchronize file operation functions to the File Explorer. In the momenet of this document been written, there are 3 main binary files. 1. fsexec 2. fszip 3. fsconv #### fsexec ArOZ Online System File Explorer - Freeze Script Execution Application, design for replacing those script that was freezing the system while file IO. ##### What is fsexec Freeze Script Execution Application - Short for fsexec, is a binary written in golang to replace the old scripts in the ArOZ Online File System that would freeze the whole PHP server during file IO operations. This script make use of golang's super fast IO and processing ability and make file operation much faster on the new implementation. The fsexec application will receive the command as two parts. In most case, you will be using these funcitons only. ./fsexec {uuid} {command} where command is a string in base64 encoded JSON string. ##### How to use fsexec For example, you want to use the funciton [copy] with paramter {source} and {target}. First, you need to convert the command into an array and parse it as JSON string. For example, you have the following command array: ``` ["copy","./test.txt","target/test.txt"] ``` Next, you would want to stringify it as JSON string. ``` "[\"copy\",\"./test.txt\",\"target/test.txt\"]" ``` Then, you can convert the string above into base64 representation. This is what you will get: ``` WyJjb3B5IiwiLi90ZXN0LnR4dCIsInRhcmdldC90ZXN0LnR4dCJd ``` Lastly, you call the fsexec with the following command. Assumeing the {uuid} is [123] ``` ./fsexec 123 WyJjb3B5IiwiLi90ZXN0LnR4dCIsInRhcmdldC90ZXN0LnR4dCJd ``` Here are some examples: ``` # copy test.txt test/test.txt ./fsexec uuid_string WyJjb3B5IiwidGVzdC50eHQiLCJmb2xkZXIvdGVzdC50eHQiXQ== # copy_folder test/ target/test/ ./fsexec uuid_string WyJjb3B5X2ZvbGRlciIsInRlc3QvIiwidGFyZ2V0L3Rlc3QvIl0= ``` #### fszip ArOZ Online System File Explorer - File System Zipping Backgroundworker, design to replace the legacy zipping PHP script. ##### What is fszip File System Zipping Backgroundworker - Short for fszip, is a backgound working script that is design to replace the current PHP based zipping method used by the file explorer. This work similar to fsexec with asynchonized design to prevent the main PHP server from freezing due to the zipping process. This is particularly useful on low power host like the Raspberry Pi Zero series. ##### How to use fszip Although we strongly recommend using the fszip via file explorer API, you can call the binary directly with the following command. ``` ./fsexec {uuid} {command_in_base64_encoded_JSON_string} ``` The command has to be in one of the format that fits the following rule ``` // Command Structure: // [{"zip" / "unzip", "{source}", "{target}"] //Examples //["zip","test","test.zip"] //Zip the folder "test" into "test.zip" ./fszip uuid1 WyJ6aXAiLCJ0ZXN0IiwidGVzdC56aXAiXQo= //["unzip","test.zip","unzip"] //Unzip the folder "test.zip" to unzip/ ./fszip uuid2 WyJ1bnppcCIsInRlc3QuemlwIiwidW56aXAiXQo= ``` #### fsconv ArOZ Online File System File Naming Method Converter - fsconv, design to do quick conversion between UM-filename and UTF8 filename on local file system. ##### What is fsconv fscov is a core library for converting Upload Manager File Naming Method that is commonly used in ArOZ Online System to UTF-8 filename that works on standard Windows + NTFS environment. This is a standalone implementation other than the original one which use Javascript in ao_module or even the older one PHP based conversion script. ##### How to use fsconv fsconv support the following methods. ``` Usage of fsconv.exe: -i string Input filename. -r Enable recursive filename translation. -rd Recursive rename directory only. -rf Recursive rename file only. -um Convert to UMfilename format -utf Convert to standard UTF-8 filename format ``` Here are some example commands ``` #Convert all files, directories and their subdirs into UTF8 filename ./fsconv -r -utf -i test/ #Convert all files, directories and their subdirs into umfilenames ./fsconv -r -um -i test/ #Convert all files and files in subdirs into umfilenames but leave out foldername. ./fsconv -rd -um -i test/ #Convert all directories and subdirs into umfilenames but leave out filenames. ./fsconv -rf -um -i test/ ``` To perform quick translations, you can also call the application with following shortcuts ``` #Convert all files in current and subdirs into UTF-8 (or local encoding) filenames ./fsconv #Convert all files in current and subdirs into um-filenames ./fsconv -um ``` #### Process States Log for fsexec and fszip The fsexec and fszip application will create a folder named "log" if it doesn't exists. Inside the log folder, you would found "done" and "error" sub-folders. In simple words: - For all successfully finished file operation, its log will be stored in "done" directory. - For all failed file operation, its log will be stored in "error" directory. - For all processing file operation, its log will be stored under "log/" directory but not its subfolders. ### File System Synchronize Function Group The Synchronize function group is a set of php scripts written since the early stage of beta phrase. They provide compatibility over the system if the backstage doesn't support binary execution / permission required is not met. **It is not recommended to use this set of function group as they will freeze the PHP server while performing the file operation. Only use them if you have encountered compatibility issues with the go-lang compiled binary files** The following is a list of functions and its intake parameter. For each paramter that require paths, *feed in relative path from the script itself or absolute path* instead of the path of your WebApp script. ``` //Copy File from source to target copy.php?from={source_path}&target={target_path} //Copy Folder from source to target copy_folder.php?from={source_path}&target={target_path} //Zip folder to file_system/export/ directory zipFolder.php?folder={source_path} //Or with defined foldername included in the zip filename zipFolder.php?folder={source_path}&foldername={foldername_in_utf8} //Move file or folder from source to target (Or rename) move.php?from={source_path}&to={target_path} ```  ## File Selector ArOZ Online File System provide a simple way to access the file list and allow users to select files within the file system of your host device - The File Selector. The file selector API can be called via the following two commands ``` //Under VDI Mode, popup as a new floatWindow ao_module_openFileSelector(uid,callBackFunctionName, windowWidth = 1080, windowHeight = 645, allowMultiple = false, selectMode = "file") //Under Normal Mode, popup as a new tab window (Require localStorage) ao_module_openFileSelectorTab(uid, aor,allowMultiple = false, selectMode = "file",callBack=console.log ``` Here is a table showing the different meaning of each parameters.
Variable | Meanings |
---|---|
uid | Unique ID for this floatWindow |
aor | ArOZ Online Root, usually ../ for WebApp moduiles |
windowWidth | The width of the file selector window. Default 1080px |
windowHeight | The height of the file selector window. Default 645px |
alowMultiple | Allow selecting multiple items in the selector. |
selectMode | Select file / folder / all. Default "file", accept {file / folder/ mix} |
callBackFunctionName (floatWindow Mode Only) | Function name that expect the selector to return the result to. THIS FUNCTION NAME IS IN STRING FORMAT |
callBack (Non floatWindow Mode Only) | Function that expect the selector to return the result to. THIS IS THE POINTER OF THE FUNCTION. |