This topic provides the sample code for adding a video file to the media library. You can specify the ID of a workflow to process the video file.

package com.aliyun.mts;
    import com.aliyuncs.DefaultAcsClient;
    import com.aliyuncs.exceptions.ClientException;
    import com.aliyuncs.exceptions.ServerException;
    import com.aliyuncs.mts.model.v20140618.AddMediaRequest;
    import com.aliyuncs.mts.model.v20140618.AddMediaResponse;
    import com.aliyuncs.profile.DefaultProfile;
    import org.apache.commons.lang.exception.ExceptionUtils;
    public class AddMedia {
        // Specify the region in which you use the ApsaraVideo Media Processing (MPS) service, the region in which you use the Object Storage Service (OSS) service, and the endpoint used to access the MPS service.
        private static final String REGION = "cn-shenzhen";
        private static final String OSS_REGION = "oss-cn-shenzhen";
        private static final String mtsEndpoint = "mts." + REGION + "";
        //Specify the AccessKey ID and the AccessKey secret.
        private static String accessKeyId = "";
        private static String accessKeySecret = "";
        private static DefaultAcsClient aliyunClient;
        static {
            try {
                DefaultProfile.addEndpoint(REGION, REGION, "Mts", mtsEndpoint);
            } catch (ClientException e) {
            aliyunClient = new DefaultAcsClient(DefaultProfile.getProfile(REGION, accessKeyId, accessKeySecret));
        public static void main(String[] args) throws ClientException {
            AddMediaRequest request = new AddMediaRequest();
            try {
                AddMediaResponse response = aliyunClient.getAcsResponse(request);
            } catch (ServerException e) {
                System.out.println("Code:" + e.getErrCode() + " Msg:" + e.getMessage());
            } catch (ClientException e) {
                System.out.println("Code:" + e.getErrCode() + " Msg:" + e.getMessage());