0
// 服务端直传 七牛云
function uploadQiniu(localFile, key, cb) {
    var accessKey = '402YZxjC6iLOTtsVn3OAedKy91Bjc6p11rVJfg6h';
    var secretKey = 'V4duV2LCuVPufV6ffqdCPuageC-DscmywGkSLLup';
    var mac = new qiniu.auth.digest.Mac(accessKey, secretKey);
    var options = { scope: 'microblog' };
    var putPolicy = new qiniu.rs.PutPolicy(options);
    var uploadToken = putPolicy.uploadToken(mac);


    var config = new qiniu.conf.Config();
    // 空间对应的机房
    config.zone = qiniu.zone.Zone_z0;
    var formUploader = new qiniu.form_up.FormUploader(config);
    var putExtra = new qiniu.form_up.PutExtra();
    // 文件上传 
    // 在本地测试时,往下就没执行了
    formUploader.putFile(uploadToken, key, localFile, putExtra, function (respErr, respBody, respInfo) {
        if (respErr) throw respErr;
        cb && cb(respBody);
    });
}

clipboard.png

大桔子 245
2018-07-25 提问
1 个回答
0

抛出什么错误了吗。我觉得你这里的本地环境如果是完全离线,肯定是失败的

撰写答案

你可能感兴趣的

推广链接