七牛云存储 - 七牛云 如何用java在服务器生成token
PHP中文网
PHP中文网 2017-04-17 17:58:31
0
2
502

我用七牛提供的jar包,引进去始终提示这样的错误。都无语了

有大神指导 指导吗?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
刘奇
    public static String getWebUptoken() {
        Config.ACCESS_KEY = PropertiesUtil.getString("qiniu.access.key");
        Config.SECRET_KEY = PropertiesUtil.getString("qiniu.secret.key");
        Mac mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
        // 请确保该bucket已经存在
        String bucketName = PropertiesUtil.getString("qiniu.bucket");
        PutPolicy putPolicy = new PutPolicy(bucketName);
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.HOUR_OF_DAY, 1);
        putPolicy.deadline = cal.getTimeInMillis() / 1000;
        String uptoken = null;
        try {
            uptoken = putPolicy.token(mac);
        } catch (AuthException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return uptoken;
PHPzhong

I also encountered the same problem. Could you please tell me how you solved it?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template