Methods
-
append_file(fileId, content, charset) → {string}
Append data to an existing file. Works only for uploaded files.
-
Append data to an existing file, or create a new file if no file is mentioned. Only work with uploaded files.
Parameters:
Name Type Argument Default Description fileIdstring Identifier of the file to be appended. A new file is created if fileId is empty. contentstring Content to be appended charsetstring <optional>
UTF-8 Character set of the content to be appended. More information about character sets Returns:
Identifier of the appended or created file- Type
- string
-
create_file(name, content, options) → {string}
Create a new file. Works only for uploaded files.
-
Parameters:
Name Type Description namestring Name of the new uploaded file. contentstring Content to be added to the file optionsfileoptions Options to create the file Returns:
Identifier of the created file- Type
- string
-
create_file(name, content, charset, contentType) → {string}
Create a new file. Works only for uploaded files.
-
Parameters:
Name Type Argument Default Description namestring Name of the new uploaded file. contentstring Content to be added to the file charsetstring <optional>
UTF-8 Character set of the content. More information about character sets contentTypestring <optional>
auto discovered media type of the content - Deprecated:
- Use @see create_file with options instead
Returns:
Identifier of the created file- Type
- string
-
delete_file(fileId) → {boolean}
Delete an existing file. Works only for uploaded files.
-
Parameters:
Name Type Description fileIdstring Identifier of the file to be deleted Returns:
- Type
- boolean
-
file_replace(fileId, search, replacedBy, flag, algorithm, charset) → {string}
Replace the occurrences of a string in a file and save it. Works only for uploaded files.
-
Parameters:
Name Type Argument Default Description fileIdstring ID of the file to be modified searchstring String or regex to matched and replaced replacedBystring Replacement string flagsearchflag <optional>
flag modifying the search method. By default `search`is considered as a plain string and all occurrences are replaced. algorithmalgorithm <optional>
none Algorithm to be used to decode the content. charsetstring <optional>
UTF-8 Character set of the content to be read. More information about character sets Returns:
File identifier- Type
- string
-
R_file_content(fileId, algorithm, charset) → {string}
Read the content of a file.
-
Parameters:
Name Type Argument Default Description fileIdstring Identifier of the file to be read algorithmalgorithm Encoding algorithm. charsetstring <optional>
UTF-8 Character set of the content to be read. More information about character sets Returns:
File content- Type
- string
-
R_file_desc(fileId) → {filedescriptor}
Get the metadata describing a file on the platform.
-
Parameters:
Name Type Description fileIdstring Identifier of the file to be read Returns:
File description- Type
- filedescriptor
-
R_file_index_of(fileId, substring, from, algorithm, charset) → {integer}
Find the index of the first occurrence of a string in a file.
-
Parameters:
Name Type Argument Default Description fileIdstring Identifier of the file to be read substringstring String to be search in the file content frominteger <optional>
0 Index to start from in the file algorithmalgorithm <optional>
none Algorithm to be used to decode the content. charsetstring <optional>
UTF-8 Character set of the content to be read. More information about character sets Returns:
Index of the first occurrence or -1 if nothing found.- Type
- integer
-
R_file_last_index_of(fileId, substring, from, algorithm, charset) → {integer}
Find the the last occurrence of a string in a file.
-
Parameters:
Name Type Argument Default Description fileIdstring Identifier of the file to be read substringstring String to be search in the file content frominteger <optional>
0 Index to start from in the file algorithmalgorithm <optional>
none Algorithm to be used to decode the content. charsetstring <optional>
UTF-8 Character set of the content to be read. More information about character sets Returns:
Index of the first occurrence or -1 if nothing found.- Type
- integer
-
R_file_size(fileId) → {integer}
Get the size in KBytes of a file on the platform.
-
Parameters:
Name Type Description fileIdstring Identifier of the file to be read Returns:
Size in KBytes- Type
- integer
-
R_file_substring(fileId, substring, from, to, algorithm, charset) → {integer}
Find the index of the first occurrence of a string in a file.
-
Parameters:
Name Type Argument Default Description fileIdstring Identifier of the file to be read substringstring String to be search in the file content frominteger <optional>
0 Index to start from in the file tointeger <optional>
end of file Index to stop at in the file algorithmalgorithm <optional>
none Algorithm to be used to decode the content. charsetstring <optional>
UTF-8 Character set of the content to be read. More information about character sets Returns:
Index of the first occurrence or -1 if nothing found.- Type
- integer
-
R_read_excel_cells(fileId, cells) → {cellsdescriptor}
Read cells from an Excel worksheet.
-
Parameters:
Name Type Description fileIdinteger Identifier of the Excel file uploaded on the platform cellsworksheet Worksheet descriptor listing the cells to be read Returns:
- Type
- cellsdescriptor
Example
// MyWorksheet is a worksheet in an Excel file uploaded with ID fe68f660-df8d-11e1-8a0e-1231390a5172 // cells = [{"worksheet":"MyWorksheet1","cells":[{"col":"1","row":"5"},{"col":"2","row":"5"},{"col":"3","row":"4"}]},{"worksheet":"MyWorksheet2","cells":[{"col":"1","row":"2"},{"col":"2","row":"2"},{"col":"3","row":"2"}]}] ${read_excel_cells("fe68f660-df8d-11e1-8a0e-1231390a5172",cells)} // returns {"MyWorksheet2":{"2":{"1":"1","2":"a value","3":""}},"MyWorksheet1":{"4":{"3":""},"5":{"1":"4","2":"another value!"}}} -
save_file(fileId, content, charset) → {string}
Overwrite an existing file. Works only for uploaded files.
-
Parameters:
Name Type Argument Default Description fileIdstring Identifier of the file to be overidden contentstring New content of the file charsetstring <optional>
UTF-8 Character set of the new content. More information about character sets - Deprecated:
- Use @see save_file with options instead
Returns:
Identifier of the file- Type
- string
-
save_file(fileId, content, options) → {string}
Overwrite an existing file. Works only for uploaded files.
-
Parameters:
Name Type Description fileIdstring Identifier of the file to be overidden contentstring New content of the file optionsfileoptions File options Returns:
Identifier of the file- Type
- string
-
save_file_desc(fileId, metadata) → {filedescriptor}
Modify the metadata describing a file on the platform.
-
Parameters:
Name Type Description fileIdstring Identifier of the file to update metadatafiledescriptor New metadata of the file Returns:
New metadata of the file.- Type
- filedescriptor
-
unzip_file(fileId) → {filedescriptor}
Unzip a file, and create a new file with the unzipped data. Works only for uploaded files.
-
Parameters:
Name Type Description fileIdstring Identifier of the file to be overidden Returns:
Metadata of the new (unzipped) file- Type
- filedescriptor
-
update_file(fileId, name, contentType) → {string}
Update file metadata. Works only for uploaded files.
-
Parameters:
Name Type Description fileIdstring Identifier of the file to be overidden namestring New name of the file contentTypestring New content type of the file - Deprecated:
- Use @see save_file_desc instead
Returns:
Identifier of the file- Type
- string
-
zip_file(fileId, name) → {string}
Zip an file, and create a new file with the zipped data. Works only for uploaded files.
-
Parameters:
Name Type Description fileIdstring | array Identifier of the file to be overidden **or** list of files to be added to the zip archive in a JSONArray format namestring Name of the new zip file to be created Returns:
Identifier of the new zip file- Type
- string