首页 > 七牛报错"error":"token not specified"

七牛报错"error":"token not specified"

客户端<script type="text/javascript">

function upLoad(uploadCallback) {
    $.ajax({
        type : 'POST',
        url : '${basePath}upload',
        success : function(dataStr, status) {
            uploadCallback(dataStr.token);
        },
        error : function(data, status, e) {
        }

    });
}

function uploadCallback(token) {
    $.ajaxFileUpload({
        url : 'http://up.qiniu.com/',
        secureuri : false,
        date : {
            'token' : token,
            'key':'test'
        },
        dataType : 'json',
        type : 'post',
        success : function(dataStr, status) {
        },
        error : function(data, status, e) {

        }
    });
}

</script>
</head>
<body>

    <input type="file" name="file" class="file-upload" id="upload"
        onchange="upLoad(
         uploadCallback
         );" />

</body>
服务端
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    Gson gson = new Gson();
    Map<String, Object> r = new HashMap<String, Object>();
    String token=QiniuConfig.getUpToken();
    r.put("token", token);
    String data = gson.toJson(r);
    response.getWriter().write(data);
    
}
/**
    • 生成Token

    • @return
      */

    1. static String getUpToken() {

         return auth
                 .uploadToken(
                         QiniuConfig.bucket,
                         null,
                         3600,
                         new StringMap()
                                 .putNotEmpty(
                                         "returnBody",
                                         "{\"key\": $(key), \"hash\": $(etag), \"width\": $(imageInfo.width), \"height\": $(imageInfo.height)}"));

      }

    自己做的demo为什么老是报错token not specified,请大神指导下

    【热门文章】
    【热门文章】