Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let options = {
scope: params.isOverwrite ? params.bucket : `${params.bucket}:${params.key}`,
};
let putPolicy = new qiniu.rs.PutPolicy(options);
let uploadToken = putPolicy.uploadToken(getToken());
let config = new qiniu.conf.Config();
let putExtra = new qiniu.resume_up.PutExtra();
putExtra.progressCallback = (uploadBytes, totalBytes) => {
if (params.progressCallback) {
params.progressCallback(parseInt((uploadBytes / totalBytes * 100)));
}
};
new qiniu.resume_up.ResumeUploader(config).putFile(uploadToken, params.key, params.path, putExtra, function (respErr, respBody, respInfo) {
if (respBody.error) {
respErr = {"error": respBody.error};
}
console.log(respErr, respBody, respInfo);
callback(respErr, respBody);
});
}
function upload(params, callback) {
let options = {
scope: params.isOverwrite ? params.bucket : `${params.bucket}:${params.key}`,
};
let putPolicy = new qiniu.rs.PutPolicy(options);
let uploadToken = putPolicy.uploadToken(getToken());
let config = new qiniu.conf.Config();
let putExtra = new qiniu.resume_up.PutExtra();
putExtra.progressCallback = (uploadBytes, totalBytes) => {
if (params.progressCallback) {
params.progressCallback(parseInt((uploadBytes / totalBytes * 100)));
}
};
new qiniu.resume_up.ResumeUploader(config).putFile(uploadToken, params.key, params.path, putExtra, function (respErr, respBody, respInfo) {
if (respBody.error) {
respErr = {"error": respBody.error};
}
console.log(respErr, respBody, respInfo);
callback(respErr, respBody);
});
}