arcgis server GP 处理大文件的方法

问题

服务器(arcgis server 10.2)发布GP服务,但浏览器解析不了百兆以上的json大文件,无法完成GP输入。

解决办法

允许GP服务的上传 功能。把大文件上传到arcgis server上,用返回的itemid作为输入值。

步骤

  1. 上传大文件
            //先上传,再GP处理
           let formData_1 = new FormData();
           formData_1.append('file', $('#mInput')[0].files[0]);
           formData_1.append('description', "待处理");
           formData_1.append('f', 'json');

           $.ajax({
               url: gpUploadURL,
               type: 'POST',
               async: true,
               cache: false,
               data: formData_1,
               processData: false,//必须
               contentType: false,//必须

               success: (response) => {

                   let itemID = JSON.parse(response).item.itemID;
                   
                   let datafile = new DataFile();
                   datafile.itemId = itemID;

                  //执行GP
               },
               error: (response) => {
                   let rData = JSON.stringify(response);
                   console.log("upload错误!" + rData);
               }
           });
  1. 执行GP
                   let parms = {
                       parm1: datafile,
                   };
                   
                  gp.submitJob(parms).then(gpJobComplete, gpJobFailed, gpJobStatus);
  1. 删除文件
function deleteUploadItem(itemUrl,token) {

    $.ajax({
        url: itemUrl,
        type: 'POST',
        data: {
            'f':'json',
            'token':token
        },
        xhrFields:{
            withCredentials:false
        },
        crossDomain:true,
        success: (response) => {
            let response_json=JSON.parse(response);
            if (response_json.status==="success")
                console.log("delete成功!");
        },
        error: (response) => {
            let rData = JSON.stringify(response);
            console.log("delete错误!" + rData);
        }
    })
}

//获取token
function OpWithToken(urlDel, Opurl) {

    let data={
        'username':'',
        'password':'',
        'client':'referer',
        'referer':window.location.href,
        'ip':'',
        'expiration':10,
        'f':'json'
    };

    $.ajax({
        url:url,
        type:'POST',
        data:data,
        xhrFields:{
            withCredentials:false
        },
        crossDomain:true,
        success: (response) => {
            let json=$.parseJSON(response);
            deleteUploadItem(urlDel,json.token)
        },
        error: (response) => {
            let error = JSON.stringify(response);
            console.log("token错误!" + error);
        }
    })
}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值