예제 #1
0
        static void Main(string[] args)
        {
            VodUploadClient  client = new VodUploadClient("secretid", "secretkey");
            VodUploadRequest req    = new VodUploadRequest();

            req.MediaFilePath = "F:\\sz-rz\\a.mp4";

            Task <VodUploadResponse> r        = client.Upload("ap-guangzhou", req);
            VodUploadResponse        response = r.Result;


            Console.Write("{0}|{1}\n", response.FileId, response.MediaUrl);

            Console.Read();
        }
예제 #2
0
        public IActionResult UploadMediaToCloud()
        {
            VodUploadClient client = new VodUploadClient("*",
                                                         "*");

            var urlPath = "/media/test.mp4";

            string webRootPath     = _hostingEnvironment.WebRootPath.Replace('\\', '/');
            string contentRootPath = _hostingEnvironment.ContentRootPath.Replace('\\', '/');
            String path            = webRootPath + urlPath;

            if (System.IO.File.Exists(path))
            {
                VodUploadRequest request = new VodUploadRequest
                {
                    MediaFilePath = path,
                    //CoverFilePath = "/data/videos/Wildlife.jpg"
                    Procedure = "Adaptive stream"
                };
                try
                {
                    VodUploadResponse response = client.Upload("ap-beijing", request);
                    // 打印媒体 FileId
                    Console.WriteLine(response.FileId);
                }
                catch (Exception e)
                {
                    // 业务方进行异常处理
                    Console.WriteLine(e);
                }
            }
            else
            {
            }

            return(Ok());
        }