上传附件
POST
https://api.itniotech.com/sms/mmsUpload
上传附件
请求示例
Request URL:
https://api.itniotech.com/sms/mmsUpload
Request Method:
POST
Request Headers:
Content-Type: application/json;charset=UTF-8
Sign: 05d7a50893e22a5c4bb3216ae3396c7c
Timestamp: 1630468800
Api-Key: bDqJFiq9
Request Body:
{
"fileType":"png",
"FileData":"MTizNDU2"
}
请求示例上传png附件:
Request URL:
https://api.itniotech.com/sms/mmsUpload
Request Method:
POST
Request Headers:
Content-Type: application/json;charset=UTF-8
Sign: 05d7a50893e22a5c4bb3216ae3396c7c
Timestamp: 1630468800
Api-Key: bDqJFiq9
Request Body:
{
"fileType":"png",
"fileData":"Base64 encoded file content"
}
响应示例
{
"status":"0",
"reason":"success",
"data":"57_3_1727059993381.txt"
}
Java-base64编码转换示例代码:
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;
}