我无法从java服务器端获取签名(java servlet)

时间:2014-06-23 15:23:11

标签: java cloudinary

我将服务器端的签名(java servlet)传递给html客户端。 这是代码:

    Cloudinary cloudinary = new Cloudinary(Cloudinary.asMap("cloud_name", "dvg8fiorp", "api_key", "742866863611915", "api_secret", "zF-GJqVyWjih_MqQGsYeSOVVmJ8"));
    String timestamp = (new Long(System.currentTimeMillis() / 1000L)).toString();
    Map<String, Object> params = new HashMap<String, Object>();
    Map options = Cloudinary.emptyMap();
    boolean returnError = Cloudinary.asBoolean(options.get("return_error"), false);
    String apiKey = Cloudinary.asString(options.get("api_key"), cloudinary.getStringConfig("api_key"));
    if (apiKey == null)
        throw new IllegalArgumentException("Must supply api_key");
    String apiSecret = Cloudinary.asString(options.get("api_secret"), cloudinary.getStringConfig("api_secret"));
    if (apiSecret == null)
        throw new IllegalArgumentException("Must supply api_secret");
    params.put("callback", "http://localhost:8080/SimpleServlet/js/cloudinary_js/html/cloudinary_cors.html");
    params.put("timestamp", timestamp);
    String expected_signature = cloudinary.apiSignRequest(params, apiSecret);

不幸的是,最后一行代码失败了,我不知道如何将签名传递给html客户端

1 个答案:

答案 0 :(得分:0)

首先,请注意您的API密码不应公开披露。我强烈建议您从安全设置页面https://cloudinary.com/console/settings/security)生成新的密钥或API密钥和密钥。

其次,这实际上生成了正确的签名,我设法成功上传了它。

为了进一步了解这个问题:

  • 你得到了什么样的错误回复?
  • 请分享您的上传请求代码。

这是服务器的回复:

java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.join(Ljava/util/Collection;Ljava/lang/String;)Ljava/lang/String;
com.cloudinary.Cloudinary.apiSignRequest(Cloudinary.java:93)
us.souther.simple.UploadServersideServlet