Home > API Center > API interface guide

 

Upload Attachment

POST

https://api.laaffic.com/v3/mmsUpload

Upload MMS attachments.
 
Request Parameters
Parameters Description Required Type
fileType Attachment type, support:[png,jpg,jpeg,bmp,gif,webp,psd,svg,tiff,mp3,wav,txt,vcf] Yes String
fileData The file is transmitted using Base64 encoding. MMS attachments support up to 50 KB, and RCS attachments support up to 300 KB. (For base64 code conversion, please refer to the JAVA sample code at the very bottom of the program) Yes String
 
Request Sample (to upload a txt attachment with the attachment content of "123456")
Request URL:
    https://api.laaffic.com/v3/mmsUpload
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "fileType":"txt",
    "fileData":"MTizNDU2"
}
 
Request Sample (upload png attachment)
Request URL:
    https://api.laaffic.com/v3/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"
}
 
Response Parameters
Parameters Description Type
status "0"means successful, others than 0 means failure, seeing Status Code description. String
reason Failure reason description String
data Upload attachment id, valid for 3 days, can be used to send MMS repeatedly within 3 days String
 
Request Sample
{
    "status":"0",
    "reason":"success",
    "data":"57_3_1727059993381.txt"
}
 
Sample code for Java-base64 code conversion:
 
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;
}

Was this page helpful?

Questions about integration? Contact our technical support

LAAFFIC API dedicated TG technical support channel, real-time response to your needs

Contact via Telegram

Telegram
WhatsApp
Chat with us!
Need help?
Click here and start chatting with us!