Home > API Center > API interface guide
| Parameters | Description | Required | Required |
|---|---|---|---|
| fileName | File name with suffix, 5-32 characters | Yes | String |
| file | Base64 encoded file content (for base64 encoding conversion, please see the JAVA sample code at the bottom of this method). File size 1Mb, Only supports MP3 WAV | Yes | String |
Request URL:
https://api.laaffic.com/v3/cc/seatGroup/upload
Request Method:
POST
Request Headers:
Content-Type: application/json;charset=UTF-8
Sign: 05d7a50893e22a5c4bb3216ae3396c7c
Timestamp: 1630468800
Api-Key: bDqJFiq9
Request Body:
{
"fileName":"test.mp3",
"file":"Base64 encoded file content"
}| Parameters | Description | Required |
|---|---|---|
| status | status code,0 is successful. For other failures, please refer to the interface response code | String |
| reason | Failure reason description | String |
| data | Object | |
| fileName | File name | String |
| fileUrl | File path | String |
{
"status": "0",
"reason": "success",
"data": {
"fileName": "turnseatring-template/120250106d88d71eb084746fcb7c77a4922d82ed1.mp3",
"fileUrl":"http://xxx"
}
}
| status | Description |
|---|---|
| 0 | Success |
| -1 | Authentication error |
| -2 | Authentication error |
| -16 | Timestamp expires |
| -18 | Port program unusual |
| -20 | Data existing |
| -21 | Data validation exception |
| -22 | Parameter exception |
| -27 | The format of the file you uploaded is incorrect. Please upload again! (Contact customer service if you have any questions.) |
| -38 | File too large |
| -39 | The uploaded file format is incorrect |
package com;
import cn.hutool.core.codec.Base64;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class Test {
public static void main(String[] args) {
File f = new File("c:\tmp\test.mp3");
System.out.println(file2Base64(f));
}
public static String file2Base64(File file) {
if(file==null) {
return null;
}
String base64 = null;
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
byte[] buff = new byte[fin.available()];
fin.read(buff);
base64 = Base64.encode(buff);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fin != null) {
try {
fin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return base64;
}
}
Questions about integration? Contact our technical support
LAAFFIC API dedicated TG technical support channel, real-time response to your needs