edit-icon download-icon

Add media

Last Updated: Mar 28, 2018

Add a video file to MEdia Files, and the user can specify workflow to be triggered to process this file:

  1. import json
  2. from aliyunsdkcore.acs_exception.exceptions import ServerException, ClientException
  3. from aliyunsdkmts.request.v20140618 import AddMediaRequest
  4. from aliyunsdkcore import client
  5. import urllib
  6. import thread
  7. # Step 1 set region
  8. REGION = "cn-shenzhen";
  9. mtsEndpoint = "mts." + REGION + ".aliyuncs.com";
  10. # Step 2.set accesskey & keySecret
  11. accessKeyId = "";
  12. accessKeySecret = "";
  13. cli = client.AcsClient(accessKeyId, accessKeySecret, REGION)
  14. def addMeida():
  15. request = AddMediaRequest.AddMediaRequest()
  16. request.set_FileURL("http://mtb-sz-in.oss-cn-shenzhen.aliyuncs.com/media/r180-ABC.mp4")
  17. request.set_MediaWorkflowId("829bed0300994057a49e4f16de957e34")
  18. try:
  19. response = cli.do_action_with_exception(request)
  20. json_response = json.loads(response)
  21. print json.dumps(json_response)
  22. except ServerException, e:
  23. print e.get_error_code(), e.get_error_msg()
  24. except ClientException, e:
  25. print e.get_error_code(), e.get_error_msg()
  26. def encodeByRFC3986(ossObject):
  27. return urllib.quote(ossObject)
  28. if __name__ == "__main__":
  29. addMeida()
Thank you! We've received your feedback.