API接口URL:

http://www.cloudroom.com/api/uploadLiveImageAPI

参数:

公共参数(查看详细

接口参数 ↓

名称 类型 是否必传 说明
LiveID Integer 直播号
ImgType String 图片类型,引导图:guideImages 、封面:coverImages 、分享图片:shareImages 、频道图:channelImages

返回数据:

名称 类型 说明
RspCode String 响应码
RspDesc String 响应描述
Data Map 数据

Data

名称 类型 说明
ImgURL String 图片地址

返回状态码RspCode说明

数值 说明
0 请求成功
1 鉴权失败
2 参数格式错误,请校对参数格式
4 传参错误,SQL注入校验不通过
5 未知错误
6 缺少必传参数
7 找不到该场直播
8 图片类型不正确
9 图片数据获取失败
10 图片文件类型不对
11 图片不能大于5M

方式一

js上传(需要支持flash)

1、下载crupload.zip(下载地址:http://www.cloudroom.com/files/crupload.zip)
2、解压放到你的服务器项目内
3、在上传页面引入上传插件,例如:
    <!-- 需要支持jQuery -->
    <script type="text/javascript" src="http://www.cloudroom.com/static/js/jquery-1.8.3.min.js"></script>
    <!-- 引入插件js -->
    <script type="text/javascript" src="http://你的域名/crupload/crupload.min.js"></script>
    </head>
    <body>
        <input type="file" id ="cruploadid">
    </body>
    <script type="text/javascript">
        $(function(){
            var params = {
                url : 'http://www.cloudroom.com/api/uploadLiveImageAPI?LiveID=12345678&ImgType=0&CompID=1&SecretKey=e10adc3949ba59abbe56e057f20f883e', //上传url及相关参数
                fileid : 'cruploadid',                        //上传文件的id
                swfurl : 'http://你的域名/crupload/crupload.swf',  //flash文件
                btnwidth : 70,   //上传按钮宽度
                btnheight : 30   //上传按钮高度
            };
            CR_UPLOAD.init(params);
        });
        CR_UPLOAD.on('onInitError', function(res) {
            // res = {ResCode:错误码, ResDesc:描述}
            alert(JSON.stringify(res));
            //初始化失败处理
        });
        CR_UPLOAD.on('onSelect', function(res) {
            // res = {fileName:图片名称, fileType:图片类型, fileSize:图片大小}
            alert(JSON.stringify(res));
            //选择成功处理
        });
        CR_UPLOAD.on('onSelectError', function(res) {
            // res = {ResCode:错误码, ResDesc:描述}
            alert(JSON.stringify(res));
            //选择文件错误处理
        });
        CR_UPLOAD.on('onUploadSuccess', function(res) {
            // res = {ResCode:错误码, ResDesc:描述, fileURL:图片地址}
            alert(JSON.stringify(res));
            //上传回调处理
        });
        CR_UPLOAD.on('onUploadError', function(res) {
            // res = {ResCode:错误码, ResDesc:描述}
            alert(JSON.stringify(res));
            //上传文件失败处理
        });
    </script>

方式二

java上传

将图片上传到你的服务器,后台由服务器转发到云屋服务器,例如:
    public void uploadFile(File file) {
        HttpClient client = null;
        PostMethod method = null;
        try{
            client = new HttpClient();
            client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
            method = new PostMethod("http://www.cloudroom.com/api/uploadLiveImageAPI?LiveID=12345678&ImgType=0&CompID=1&SecretKey=e10adc3949ba59abbe56e057f20f883e");  
            FilePart fp = new FilePart("image", file); 
            fp.setContentType(new MimetypesFileTypeMap().getContentType(file))
            StringPart jsonBody = new StringPart("jsonBody", "{}", "utf-8");
            Part[] parts = {jsonBody,fp}; 
            MultipartRequestEntity mre=new MultipartRequestEntity(parts,method.getParams());
            method.setRequestEntity(mre);
            int code = client.executeMethod(method);
            if(code!=HttpStatus.SC_OK){
                throw new Exception("");
            }
            String respText = method.getResponseBodyAsString();
            System.out.println(respText);
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            if(method!=null){
                method.releaseConnection();
            }
            if(client!=null){
                client.getHttpConnectionManager().closeIdleConnections(1);
            }
        }
    }


© HeDonghai all right reserved,powered by Gitbook文件修订时间: 2018-11-20 14:29:10

results matching ""

    No results matching ""