English
Fx.file
About 3641 wordsAbout 12 min
2026-01-09
1. uploadFile File Upload
File Upload
Fx.file.uploadFile(<String extensionName>, <Integer fileSize>, <byte[] fileBytes>, <Integer userId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| extensionName | String | File extension | Y |
| fileSize | Integer | File size | Y |
| fileBytes | byte[] | File content byte array | Y |
| userId | Integer | Username | -- |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Error status flag |
| data | Map | |
| message | String | Status message |
| data | Map | Description |
|---|---|---|
| extensionName | String | File extension name |
| path | String | File path |
| size | Integer | File size |
Return an example
{
"isError": false,
"data": {
"extensionName": ".xlsx",
"path": "N_202411_11_f20d33d4520e49738be560448001b451",
"size": 25
},
"message": ""
}Code examples
def text = "aaa" as String
def byteData = Strings.toUTF8Bytes(text)
def ret = Fx.file.uploadFile(".txt", byteData.size(), byteData, 1000)
def data = ret.data
log.info(data)
log.info(data['path'])
log.info(data['size'])
log.info(data['extensionName'])Notice
- When processing the results with this interface, use 'def' to receive them and avoid casting as Map.
2. uploadFileByStream Upload files from external interfaces
Upload files from external interfaces
Fx.file.uploadFileByStream(<Request request>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| request | Request | Request body | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | Map | |
| message | String | Message |
| data | Map | Description |
|---|---|---|
| extensionName | String | File extension |
| fileName | String | File name |
| path | String | File path |
| size | Integer | File size |
Return an example
{
"isError": false,
"data": {
"extensionName": ".xlsx",
"fileName": "123tom.xlsx",
"path": "N_202411_11_f20d33d4520e49738be560448001b451",
"size": 25
},
"message": ""
}Code examples
Map map = ["id": "123", "name": "tom"]
StringBody body = StringBody.builder().content(map).build()
Request request = Request.builder()
.method("POST")
.url('http://www.baidu.com/image/download')
.timeout(7000)
.retryCount(0)
.header("Content-Type", "application/json")
.body(body)
.build()
def res = Fx.file.uploadFileByStream(request)
log.info(res.data)
//path=N_202411_11_8ae08f8997c84e1f984bf7515ad6a1be, size=25, extensionName=.xlsx, fileName=123tom.xlsxReference Interface
- Reference guide: Request
Notice
- If the response header contains Content-Length indicating the file size, file stream processing will skip file size validation; if not included, the file size will be validated and must not exceed 5MB.
- .header('Transfer-Encoding', 'gzip').header('Accept-Encoding','identity') --Adding these two headers may prompt the receiving service to include Content-Length in its response headers under certain scenarios.
3. downloadFile returns byte[] for file download
File download returns byte[]
Fx.file.downloadFile(<String path>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| path | String | Path | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | FileDownloadData | |
| message | String | Message |
| data | FileDownloadData | Description |
|---|---|---|
| extensionName | String | File extension name |
| fileName | String | File name |
| fileData | byte[] | File content |
| fileSize | Integer | File size |
Return an example
{
"isError": false,
"data": {
"extensionName": ".xlsx",
"fileName": "123tom.xlsx",
"fileSize": 25
},
"message": ""
}Code examples
def ret = Fx.file.downloadFile("N_202007_12_001731386ccf40698523c39744b0161c")
def fileDowloadData = ret[1]
def fileData = fileDowloadData['fileData'] as byte[]
def str = Strings.toUTF8String(fileData) as StringReference Interface
- Reference guide: FileDownloadData
Notice
- There is a 10MB limit for file downloads
4. downloadStream Returns InputStream for file download
File download returns InputStream
Fx.file.downloadStream(<String path>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| path | String | Path | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | FileDownloadData | |
| message | String | Message |
| data | FileDownloadData | Description |
|---|---|---|
| extensionName | String | File extension |
| fileName | String | File name |
| inputStream | InputStream | File stream |
| fileSize | Integer | File size |
Return an example
{
"isError": false,
"data": {
"extensionName": ".xlsx",
"fileName": "123tom.xlsx",
"fileSize": 25
},
"message": ""
}Code examples
def(Boolean err, Object fileData, String msg) = Fx.file.downloadStream("N_202111_29_6eb71dca766944c582b87e6a5213f3a3.docx")
if (err) {
log.info("downloadStream error :" + msg)
} else {
log.info("file data :" + fileData)
}
InputStream inputStream = fileData['inputStream'] as InputStream
log.info(fileData)Reference Interface
- Reference guide: FileDownloadData
5. packedFile packs the listed files into a compressed archive and returns the download URL.
Compress the list of files into a single archive and return the download URL.
Fx.file.packedFile(<List files>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| files | List | File path list | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | boolean | Indicates whether an error occurred |
| data | Map | Response data |
| message | string | Status message |
Return an example
{
"isError" : false,
"data" : {},
"message" : ""
}Code examples
List files = [
[
"Name":"888.jpg",
"Path":"N_202201_24_db48abc2723d4d978f240f0fb9bf35ac.webp"
]
]
def (Boolean error, Map data, String message) = Fx.file.packedFile(files)
if (error) {
log.info("error :" + message)
} else {
log.info(data)
}Notice
- Return data type: Map {"status":0, "token":"xxxxx"}, where status 0 indicates success and token represents the download address code. Status 1 indicates timeout with no download address code generated.
6. packedFile Send packed files to specified users
Send packaged files to designated users
Fx.file.packedFile(<List files>, <List userIds>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| files | List[string] | File list | Y |
| userIds | List[string] | Recipient user list | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | boolean | Indicates if an error occurred |
| data | Map | Response data |
| message | string | Status message |
Return an example
{
"isError" : false,
"data" : {},
"message" : ""
}Code examples
// Define the files to be packed and sent. Parameters are: packed file name, file path under the object (can be queried via the find function), file extension, and storage path within the package after packing.
UserFile file = UserFile.of("File1", "N_201907_31_57a33fb0c999447bb93fa1e4cc6e649d", "jpg", "/image")
List packFileList = []
packFileList.add(file)
// Pack the files in fileList and send them to the specified recipient via the personnel ID parameter
final APIResult result = Fx.file.packedFile(packFileList, Lists.newArrayList("1000"));7. createFileShareTokens Generate file download tokens for unauthorized file access
Unauthorized file download, obtaining file download token
Fx.file.createFileShareTokens(<List paths>, <String expireMinute>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| paths | List[string] | File path list | Y |
| expireMinute | String | Expiration time in minutes (maximum supported: 15 minutes) | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Error flag |
| data | object | Response data |
| message | String | Message |
Return an example
{
"isError": false,
"data": {
},
"message": "success"
}Code examples
// Get shareToken for files without permission
List paths = ['N_202102_03_54c5ede542154b748c6f9381d96a1956']
// Get shareToken for files without permission
def(boolean error, Map data, String errorMessage) = Fx.file.createFileShareTokens(5, paths)
if (error) {
log.info(errorMessage)
} else {
log.info(data)
}
// Use the following link to download the file after obtaining the shareToken:
// http://www.fxiaoke.com/FSC/N/FileShare/DownloadFileBySharedTokenV2?sharedToken=6AA905C78D85C91D796261356AF7467E53719536C4515B3328F7D65FC8476DC777DE783881DF4588EB6B9F0AEEF0F46060EA5D49185941B59C4531F5967FA07B7424EDF8BF20F11F6AE89573CF7F96735EC0284E1F637AE3&name=111.jpg8. getPresignedUrl Obtain presigned URL for attachments (exclusive to file-dedicated enterprises)
Obtain attachment presigned URL (exclusive to file-dedicated enterprises)
Fx.file.getPresignedUrl(<List paths>, <Integer expire>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| paths | List[string] | Collection of file paths | Y |
| expire | Integer | Expiration time (in seconds) | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Error status flag |
| data | array[object] | Response data |
| message | String | Message |
| data | object | Description |
|---|---|---|
| path | String | File path |
| url | String | File URL |
Return an example
{
"isError": false,
"data": [
{
"path": "N_202410_22_a981ae9fe95c43bea8ee8aaebc0c9490.pdf",
"url": ""
}
],
"message": ""
}Code examples
List npaths = ["N_202207_06_2b51df0dd11043ee9c0ad341742f95bb"]
int expire = 100
def(boolean error, List data, String message) = Fx.file.getPresignedUrl(npaths, expire)
if (error) {
log.info("error: " + message)
} else {
log.info(data)
}Notice
- No need to include the suffix
9. convertPath Convert to permission-free npath
Convert to permission-free npath
Fx.file.convertPath(<String path>, <String extension_name>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| path | String | File path | Y |
| extension_name | String | File extension | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | array[object] | Response data |
| message | String | Message |
| data | object | Description |
|---|---|---|
| path | File path | Path of the file |
| extension_name | File extension | Extension name of the file |
Return an example
{
"isError": false,
"data": [
{
"path": "N_202411_05_3df5da66c3d548a48792d75ed4bc7582",
"extension_name": "pdf"
}
],
"message": ""
}Code examples
def (Boolean error, Map data, String message) = Fx.file.convertPath("N_202208_01_3628e0ba470b4086aa04dd8f3e93ed5a")
if (error) {
log.info("error :" + message)
} else {
log.info(data)
}Notice
- The user must have permission to access the file corresponding to the input Npath.
10. wordToPdf Convert Word documents on Fenxiang to PDF
Convert Word documents from Fenxiang to PDF
Fx.file.wordToPdf(<String npath>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| npath | String | File npath | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | List | Response data |
| message | String | Message |
| data | List | Response data |
|---|---|---|
| pageCount | Integer | Total number of pages |
| employeeId | Integer | Employee ID |
| ea | Integer | ea |
| npaths | List[String] | List of npaths |
| fileType | String | File type |
Return an example
{
"isError": false,
"data": {
"pageCount": 1,
"employeeId": -10000,
"ea": 90325,
"npaths": [
"TN_c50f77531989492aba2765f2247371d5"
],
"fileType": "pdf"
},
"message": "Operation successful"
}Code examples
// The file NPath needs to include the extension. For new version files where NPath already contains the extension, do not append it again. For old NPath without extensions, the extension must be appended.
def (Boolean error, Map data, String message) = Fx.file.wordToPdf("N_202303_08_e11c1c5bb1c0486d83c5a6ece65a902f.docx")
if (error) {
log.info("error :" + message)
} else {
log.info(data)
}Notice
- The user must have permission for the file
11. getPdfMetaInfo Get the page count of PDF files
Get the page count of a PDF file
Fx.file.getPdfMetaInfo(<String npath>)
Request parameters
Request Body
| Parameter Name | String | Description | Required |
|---|---|---|---|
| npath | String | File path supporting A, N, TA, TN file types. Must include file extension | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Whether an error occurred |
| data | object | Response data |
| message | String | Message |
| data | object | Response data |
|---|---|---|
| pageCount | Integer | Page count |
| employeeId | Integer | Employee ID |
Return an example
{
"isError": false,
"data": {
"pageCount": 8,
"employeeId": 0
},
"message": ""
}Code examples
String npath = "N_202211_22_42918a541aed45038f3ab7cfdfb99aeb.pdf";
def(boolean error, Map data, String message) = Fx.file.getPdfMetaInfo(npath);
Integer pageCount = 0
if(error){
log.info("error:" + message);
}else{
log.info("PDF document info:" + data);
pageCount = (Integer) data.pageCount;
log.info("PDF page count:" + pageCount);
}12. mergerPdf appends and merges PDFs in the order of the collection
Append and merge PDFs in the order of collections
Fx.file.mergerPdf(<List npaths>, <String documentType>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| npaths | List[string] | File paths to be merged | Y |
| documentType | String | File type suffix to be merged (without dot) | Y |
Return Parameters
| Parameter Name | APIResponse | Description |
|---|---|---|
| isError | Boolean | Indicates whether the request encountered an error |
| data | object | Response data |
| message | String | Request result message |
| data | object | Response data |
|---|---|---|
| employeeId | Integer | Employee ID |
| ea | Integer | Enterprise account |
| npaths | List[string] | Collection of npaths |
| fileType | String | File type |
Return an example
{
"isError": false,
"data": {
"employeeId": 1000,
"ea": 90325,
"npaths": [
"TN_fcdc479583414586a36fde4a6c2fed9a"
],
"fileType": "pdf"
},
"message": "success"
}Code examples
List<String> npaths = Lists.newArrayList(
"N_202410_21_093c72730bdd41e1b02d98510729330b.pdf",
"N_202410_22_a981ae9fe95c43bea8ee8aaebc0c9490.pdf"
);
String documentType = "pdf";
def (boolean error, Map data, String message) = Fx.file.mergePdf(npaths, documentType);
if (error) {
log.info("Error: " + message);
} else {
log.info("Merged file information: " + data);
List mergedNpaths = data.npaths as List;
String masterNpath = mergedNpaths[0];
log.info("Merged PDF file path: " + masterNpath);
}13. getBigFilePresignedUrl Obtain presigned URL for large files
Get signed URL for large files
Fx.file.getBigFilePresignedUrl(<String filePath>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| filePath | String | ALI_OSS path for large files | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred during the request |
| data | object | Returned data |
| message | Message | Request result message |
| data | object | Returned data |
|---|---|---|
| url | String | File download URL |
Return an example
{
"isError": false,
"data": {
"url": ""
},
"message": "Request successful, file is available for download"
}Code examples
def (Boolean error, Map data, String message) = Fx.file.getBigFilePresignedUrl("ALIOSS_851a3c46b81f4adaba45c2965892dd09")
if (error) {
log.info("error :" + message)
} else {
log.info(data)
}Notice
- Note the distinction between large files and regular files. Large files are those with names starting with "ALIOSS_"!!!
14. generateQRCode generates a QR code or barcode from text and returns it in the form of Cpath or Npath.
Generate QR codes or barcodes from text and return them in the form of Cpath or Npath.
Fx.file.generateQRCode(<string content>, <String fileName>, <Integer size>, <Boolean encode>, <Boolean needCdn>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| content | string | Content to be converted into QRCode (non-empty) | Y |
| fileName | String | Default source file name for download (default: QRCode) | Y |
| size | Integer | Image size (default: 400) | Y |
| encode | Boolean | Whether to use base64 encoding for content (default: false, uses URL encoding) | Y |
| needCdn | Boolean | Whether CDN acceleration is required (if true returns Cpath, default false returns Npath) | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | boolean | Indicates whether the request encountered an error, where false represents a successful request |
| data | object | Contains the primary data returned by the request |
| message | string | The result message of the request, typically used to inform the user |
| data | object | Contains the primary data returned by the request |
|---|---|---|
| encode | boolean | Indicates whether the content is Base64-encoded, where false indicates URL encoding |
| path | string | The path of the generated QR code or barcode image |
| fileName | string | The default source file name for download, with QRCode as the default value |
| needCdn | boolean | Indicates whether CDN acceleration is required, where true means it is needed |
| size | string | The size of the QR code or barcode |
| employeeId | integer | Employee ID |
| ea | integer | ea |
| content | string | The content converted into a QR code or barcode |
Return an example
{
"isError": false,
"data": {
"encode": false,
"path": "N_202411_05_c71f3e81b6344eb9a823d10cbe3fe554",
"fileName": "QRCode",
"needCdn": false,
"size": "400*400",
"employeeId": 1000,
"ea": 90325,
"content": "http://weixin.qq.com/q/02Z6nOpuoT8__1jyGaNA1Q"
},
"message": "Request successful, file is available for download"
}Code examples
// The content to be converted into QRCode (non-empty)
String content = "http%3A%2F%2Fweixin.qq.com%2Fq%2F02Z6nOpuoT8__1jyGaNA1Q";
// Default filename when downloading the generated QRCode Image via file service using Npath or Cpath. Default is "QRcode"
String fileName = "QRCode";
// Size of the generated image, default is 400.
Integer size=400;
// Whether the content is Base64 encoded, default is false (URL encoded)
// Why encoding? Special characters may cause request failure or QRCode generation failure
boolean encode = false;
// Whether CDN acceleration is needed. true returns Cpath, default false returns Npath
boolean needCdn = false;
def(boolean error, Map data, String message) = Fx.file.generateQRCode(content, fileName, size, encode, needCdn);
if (error) {
log.info("error:" + message)
} else {
log.info("data:" + data)
}Notice
- Pay attention to whether encode is true or false.
- If you need to create barcodes, please use the function 【Fx.file.generateBarCode】. The current function can only generate QR codes (to be deprecated), while generateBarCode supports both QR codes and barcodes. We recommend using the new function.
15. asyncPackageFile Asynchronously batch packages files and sends CRM notifications to both the operator and designated recipients.
Asynchronously batch package files, submit packaging tasks, and notify both the task submitter and designated users who require notification.
Fx.file.asyncPackageFile(<List notifies>, <Map queryParam>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| notifies | List[object] | Collection of user IDs to be notified | Y |
| queryParam | Map | Packaging parameters | Y |
| notifies | object | Description | Required |
|---|---|---|---|
| userId | String | User ID | Y |
| queryParam | Map | Packaging parameters | Required |
|---|---|---|---|
| documents | List | Information of packaged files | Y |
| skipDuplicatedFile | Boolean | Whether to skip duplicate files. true: skip, false: keep duplicates | Y |
| securityGroup | String | File security group. For network disk files, include 'XiaoKeNetDisk' | -- |
| fileName | File name | Name of the packaged file with .zip extension | Y |
| documents | List | Information of packaged files | Required |
|---|---|---|---|
| files | List[object] | List of file information | Y |
| files | object | Description | Required |
|---|---|---|---|
| Name | String | Complete file name including extension | Y |
| Path | String | File path | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | boolean | Indicates whether an error occurred |
| data | Map | Returned task data |
| errorMessage | string | Error message |
| data | Map | Returned task data |
|---|---|---|
| id | string | Task ID |
| status | integer | Task status, where 0 indicates successful task submission |
Return an example
{
"isError": false,
"data": {
"id": "67385e8385210a0007797c74",
"status": 0
},
"message": ""
}Code examples
List notifies = [
[userId: "1000"],
[userId: "1002"]
]
Map queryParam = [
documents: [
files: [
[
Name: "Qingpu.zip",
Path: "N_202410_15_c545828e983e4c20aabd5aba8510ebae.zip"
]
]
],
skipDuplicatedFile : false,
securityGroup: "XiaoKeNetDisk",
fileName: "PackageFileTest.zip"
]
def (Boolean error, Map data, String errorMessage) = Fx.biz.callAPI("Fx.file.asyncPackageFile",notifies,queryParam)
if (error) {
log.info("error :" + message)
} else {
log.info(data.status)
log.info(message)
log.info(error)
}Notice
- The parameter must be set for downloading files from the cloud drive: securityGroup: "XiaoKeNetDisk"
- Custom download filenames must include the .zip extension
- Mandatory parameters must be included!!
16. Generate QR codes or barcodes from text and return them in the form of Cpath or Npath.
Generate QR codes or barcodes from text and return them in the form of Cpath or Npath.
Fx.file.generateBarCode(<string content>, <String fileName>, <String size>, <Boolean encode>, <Boolean needCdn>, <String codeModel>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| content | string | Content to be converted into Code, non-null | Y |
| fileName | String | Default source file name for download | Y |
| size | String | Size of the generated image in pixels. For QR codes, specify as 400400 (use '' between numbers), with maximum limit of 700700 and minimum width/height of 0. Recommended size is 400400, maintaining equal width and height. For barcodes, no input required (default: 450*150). | Y |
| encode | Boolean | Whether to use base64 encoding for content. Default is false (URL encoding used). | Y |
| needCdn | Boolean | Whether CDN acceleration is needed. Returns Cpath if true, otherwise returns Npath (default: false). | Y |
| codeModel | String | Type of required code: BarCode for barcode, QRCode for QR code. This field is mandatory with no default type. Errors will occur if unselected. | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | boolean | Indicates whether the request encountered an error, where false represents a successful request |
| data | object | Contains the primary data returned by the request |
| message | string | The result message of the request, typically used to inform the user |
| data | object | Contains the primary data returned by the request |
|---|---|---|
| encode | boolean | Indicates whether the content is Base64-encoded, where false indicates URL encoding |
| path | string | The path of the generated QR code or barcode image |
| fileName | string | The default source file name for download, with QRCode as the default value |
| needCdn | boolean | Indicates whether CDN acceleration is required, where true means it is needed |
| size | string | The size of the QR code or barcode |
| employeeId | integer | Employee ID |
| ea | integer | ea |
| content | string | The content converted into a QR code or barcode |
Return an example
{
"isError": false,
"data": {
"encode": false,
"path": "N_202411_05_c71f3e81b6344eb9a823d10cbe3fe554",
"fileName": "QRCode",
"needCdn": false,
"size": "400*400",
"employeeId": 1000,
"ea": 90325,
"content": "http://weixin.qq.com/q/02Z6nOpuoT8__1jyGaNA1Q"
},
"message": "Request successful, file is available for download"
}Code examples
// The content to be converted into QRCode. If BarCode is selected, the content size is limited to 100 characters. (Non-empty)
String content = "http%3A%2F%2Fweixin.qq.com%2Fq%2F02Z6nOpuoT8__1jyGaNA1Q";
// After generating the QRCode Image, the default filename for downloading via file service using Npath or Cpath. Default: QRcode
String fileName = "QRCode";
// The size of the generated image, in pixels. For QRCode, the parameter should be set like 400*400 (numbers separated by "*"). The maximum size limit for QRCode is 700*700, and the minimum width/height is 0. Recommended size is 400*400, with equal width and height. For BarCode, no input is required; the default is 450*150.
String size="400*400";
// Whether Base64 encoding is applied to the content. Default: false (URL encoding)
// Why encoding? Special characters may cause request failure or QRCode generation failure.
boolean encode = false;
// Whether CDN acceleration is needed. true returns Cpath; false returns Npath (default).
boolean needCdn = false;
// The type of code to generate: BarCode (barcode) or QRCode (QR code). This field is mandatory; no default type is provided. An error will occur if not selected.
String codeModel="QRCode";
def(boolean error, Map data, String message) = Fx.biz.callAPI("Fx.file.generateBarCode",content, fileName, size, encode, needCdn, codeModel);
if (error) {
log.info("error:" + message)
} else {
log.info("data:" + data)
}Notice
- Pay attention to whether encode is true or false
17. Delete large attachment by path
Delete large attachment by path
Fx.file.deleteBigFile(<string path>)
Request parameters
Request Body
| Parameter Name | String | Description | Required |
|---|---|---|---|
| path | string | Large attachment path | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| code | integer | Indicates the request processing status |
| data | Type | Response data returned by the request |
| success | boolean | Whether the operation succeeded |
| message | string | Request processing message |
Return an example
{
"code": 200,
"data": true,
"success": true,
"message": "Request successful"
}Code examples
String path = "ALIOSS_338bdf957ef64507b457168c821d4f72"
def (Boolean error, Map data, String errorMessage) = Fx.biz.callAPI("Fx.file.deleteBigFile", path)
if (error) {
log.info("error :" + message)
} else {
log.info(data)
}Notice
- Files will become inaccessible after deletion
18. Query asynchronous packaging task status
Query the status and packaging results of the current task based on the jobId returned by Fx.file.asyncPackageFile.
Fx.file.queryBatchStatus(<string jobId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| jobId | string | Job ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| id | string | jobId |
| fileExt | string | File extension, e.g. zip |
| url | string | Complete download URL of the file (Base64 encoded) |
| status | integer | Status code indicating the task state |
Return an example
{
"id": "jobId",
"fileExt": "zip",
"url": "Base64-encoded download URL",
"status": 2
}Code examples
def (Boolean error, Map data, String errorMessage) = Fx.biz.callAPI("Fx.file.queryBatchStatus", "yourJobId")
if (error) {
log.info("error :" + message)
} else {
log.info(data)
}Notice
- Status Code | Status Name
- ------|-------------
- 0 | Pending
- 1 | Running
- 2 | Success
- 3 | Failed
- 4 | Error
- 5 | Canceling
- 6 | Canceled
- 7 | Cancel Requested
- 8 | Unknown
- Only JobId returned by Fx.file.asyncPackageFile can be queried
18. Parse Excel files and process data with custom logic via consumer
Parse Excel files with custom processing logic defined by the consumer
Fx.file.parseExcel(<String nPath>, <String sheet>, <Integer startRow>, <Consumer<Map> consumer>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| nPath | String | File npath | Y |
| sheet | String | Sheet name (will skip processing if not matched) | Y |
| startRow | Integer | Values <=0 will be treated as 0. 0 represents the header row, with subsequent rows counted accordingly. Defaults to 1 when null | Y |
| consumer | Consumer<Map> | Custom processing logic | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| error | Boolean | Indicates whether an error occurred |
| data | Map | Response data |
| message | String | Message |
Return an example
{
"isError": false,
"data": {},
"message": ""
}Code examples
String npath = "N_202408_05_4210a63c2d5440809b4fad72884f3ef6.xlsx"
String sheet = "Sheet1"
Integer startRow = 0
def ret = Fx.file.parseExcel(npath, sheet, startRow, { e ->
Fx.object.create("object_1yO4J__c", e, , CreateAttribute.builder().build()).result()
})
log.info(ret)Notice
- Large attachments not supported
Owner:斯作益seth
Reference object com.fxiaoke.functions.http.Request
Field description
| Parameter Name | object | Description |
|---|---|---|
| headers | java.util.Map<java.lang.String,java.util.List<java.lang.String>> | Request headers |
| method | java.lang.String | HTTP method (POST/GET/PUT...) |
| retryCount | java.lang.Integer | Retry count (0 means no retry, maximum 3 retries) |
| insecure | java.lang.Boolean | Whether to bypass SSL verification (default: false) |
| body | com.fxiaoke.functions.http.RequestBody | Request body |
| timeout | java.lang.Integer | Timeout duration (maximum 120 seconds) |
| url | java.lang.String | Request URL |
Reference object com.fxiaoke.functions.model.FileDownloadData
Field description
| Parameter Name | object | Description |
|---|---|---|
| extensionName | java.lang.String | File extension |
| fileName | java.lang.String | File name |
| fileSize | long | File size |
| fileData | byte[] | File byte array |
