最大doPost()/ ajax数据大小

时间:2015-07-30 17:36:36

标签: javascript ajax google-apps-script

我已经使用已发布的页面和应用脚本创建了一段时间的驱动器文件,但现在已经要求从外部链接创建它们了,我已经创建了一个Snippet来从POST获取base64数据为它创建一个Drive文件,对于< 8kb数据效果很好,任何大于它的东西都会引发GET错误,而我的有限知识无法调试。

唯一的limitation that's near this is the 8kb for headers size,但这不是它,或者我将其作为标题发送?

以下是设置:

已发布的Code.gs:

function doPost( e ) {
  var returnMsg;

  try{
    var splitBase = (e.parameter.base64).split(','),
        type = splitBase[0].split(';')[0].replace('data:',''),
        nomeArq = (new Date()).getTime();

    var byteCharacters = Utilities.base64Decode(splitBase[1]);
    var ss = Utilities.newBlob(byteCharacters, type);
    ss.setName(nomeArq);

    var file = DriveApp.createFile(ss);

    returnMsg = file.getId();
  }catch(e){
    returnMsg = 'Erro: ' + e.toString();
  }

  return ContentService.createTextOutput( returnMsg );
}

Ajax调用有效的外部网站(< 8kb数据):

function sendPostData() {
    params = 'base64=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAO9SURBVDhPfZJrbBRVFMfPvTM7u7O7s7tlS9tsA+4CXZVXoG5aQGNtSyI1Rqlp4wMFQTC2H3xgIBSIfvBDCUG+aLAxWkkgGhUSTVRESduUIthaTKnLpl2DqSLQsG133efMnXuvd9pG2oT4z+TOnJv/78zJOQdxzmG+yE+X9M9Pk/N9LDEBnCOPx1YVsTdtVhoeBYxnTQBZUpgHk/7B7L6DdOiKFdjtwooAEGNywVAMU1q8mLW//fvGSNfoxc9i3Ut8gTuw/u2ZzLZd1pfAEBKYQkFhnGD0h1e+GFC6A/IvAUe83AvZFJhGW23rLGz0nk8/3gROFWRZYE7CHYRHS5QTK1xfLXOOlMggA5gUiAmUiWrA1Dsa37FgdnM8+WAtz2ZBUeyUq4SfCdpb6rzXyzBgCWzekKdskbaw1O0vVjWXzSlhnCtkW5c3WHBmz/7Ch51Yc7sIH3PjlhqtqypQGVzbXB6p9y1dxl2+LEHZHBQM0A1gDGQMqhPWVSKm61OrIjz1j8akvmLY8eK9VQ89tt++es1AHPp/1eOjRiJB02lGDFEwF6QQY0jC3ku9iAwMpjY96cTyoIvs+uCFT3H12s5vcl1dhXyGKwrIkjUe0T6rg+IEUapIQIhedKgdm9GrCjFjGrz3fmvsdD781CsT577P2xD4vMipIkVBooWShMTYsJVDNehAJEg1NxsexjCVzDPz7Lb6YydiqS+/KPjcSFWF1SpvvsRUFJNdLnWkV4aLJtM0m8OyQx1ZXl53Gxxnu023c3rAd5fEOC4YH7XUPTI8bhAi6sIoFPT6/BU/DOiq8j8kZtybN3c0LHi+okbrH6JiXKF7sLSheunoLUil5u7tXIlqZcrdurm9zh068m59W0eOGsgmK7U1WNfc1yP3Oww645srK+TcRRgFtrnByw/sbj95dTIeFddSuEJevQr33LxSH771p9/hMTie3tWZR2AOk2uEx4rklU/7fG+89sntYOrwYe5yAaXq7leFBS9SfH/7ePXWwNdhV1GW+jPUn7POBTl6zStv3eip3OLa+fqhk9L6zM4W0ybzZFJparQ3NQrYWs+jg6fe/PEoOGVPCm+4ofvzbMKB+krljIeWBFZ89+yRB3pGppqbxX7xdMa+5Rmts0OQs7B49fw1dPDC8QvjMaCF6RYp9xWH9qx/bnvoYXTs44m9+8QdKvarL7/kPLB3hrQk4P90LXlDZDk3djmaGLPi3p/Tm55IaAsn16zLtL1ljsanXXc0++e7yKTmb1EQK1lSIpWVzl7OFcC/7h3OG6Ox3twAAAAASUVORK5CYII=';
    params = params.replace(/\+/g,'%2b');

    url = #ThePublishedUrl#/exec;

    $.ajax({
        crossDomain : true,
        url : url,
        type : 'post',
        data : params,
        dataType : 'jsonp',
        contentType : 'jsonp',
        processData : false,
        success : function (data) {
            alert(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
         alert("some error");
        }
    });
}

0 个答案:

没有答案