Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qiniu

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qiniu - npm Package Compare versions

Comparing version 7.0.6 to 7.0.7

4

CHANGELOG.md
## CHANGE LOG
### v7.0.7
- 给form upload添加默认的crc32校验以避免网络层面的字节反转导致上传内容不正确
- 修复resume upload在上传小文件的时候出现的上传失败情况
### v7.0.6

@@ -4,0 +8,0 @@ - 修复时间戳防盗链算法中对文件名的urlencode不兼容问题

2

examples/create_uptoken.js

@@ -8,3 +8,3 @@ const qiniu = require("qiniu");

var bucket = 'if-pbl';
var bucket = proc.env.QINIU_TEST_BUCKET;

@@ -11,0 +11,0 @@ //简单上传凭证

@@ -1,5 +0,5 @@

const qiniu = require("qiniu");
const qiniu = require("../index.js");
const proc = require("process");
var bucket = 'if-pbl';
var bucket = proc.env.QINIU_TEST_BUCKET;
var accessKey = proc.env.QINIU_ACCESS_KEY;

@@ -6,0 +6,0 @@ var secretKey = proc.env.QINIU_SECRET_KEY;

@@ -1,5 +0,5 @@

const qiniu = require("qiniu");
const qiniu = require("../index.js");
const proc = require("process");
var bucket = 'if-pbl';
var bucket = proc.env.QINIU_TEST_BUCKET;
var accessKey = proc.env.QINIU_ACCESS_KEY;

@@ -6,0 +6,0 @@ var secretKey = proc.env.QINIU_SECRET_KEY;

@@ -10,3 +10,3 @@ const qiniu = require("qiniu");

var srcBucket = 'if-pbl';
var srcBucket = proc.env.QINIU_TEST_BUCKET;

@@ -13,0 +13,0 @@ //每个operations的数量不可以超过1000个,如果总数量超过1000,需要分批发送

@@ -10,3 +10,3 @@ const qiniu = require("qiniu");

var srcBucket = 'if-pbl';
var srcBucket = proc.env.QINIU_TEST_BUCKET;

@@ -13,0 +13,0 @@ //每个operations的数量不可以超过1000个,如果总数量超过1000,需要分批发送

@@ -10,3 +10,3 @@ const qiniu = require("qiniu");

var srcBucket = 'if-pbl';
var srcBucket = proc.env.QINIU_TEST_BUCKET;
var srcKey = 'qiniu.mp4';

@@ -13,0 +13,0 @@ var destBucket = srcBucket;

@@ -10,3 +10,3 @@ const qiniu = require("qiniu");

var srcBucket = 'if-pbl';
var srcBucket = proc.env.QINIU_TEST_BUCKET;

@@ -13,0 +13,0 @@ //每个operations的数量不可以超过1000个,如果总数量超过1000,需要分批发送

@@ -10,3 +10,3 @@ const qiniu = require("qiniu");

var srcBucket = 'if-pbl';
var srcBucket = proc.env.QINIU_TEST_BUCKET;

@@ -13,0 +13,0 @@ //每个operations的数量不可以超过1000个,如果总数量超过1000,需要分批发送

@@ -10,3 +10,3 @@ const qiniu = require("qiniu");

var srcBucket = 'if-pbl';
var srcBucket = proc.env.QINIU_TEST_BUCKET;
var destBucket = srcBucket;

@@ -13,0 +13,0 @@

@@ -10,3 +10,3 @@ const qiniu = require("qiniu");

var srcBucket = 'if-pbl';
var srcBucket = proc.env.QINIU_TEST_BUCKET;

@@ -13,0 +13,0 @@ //每个operations的数量不可以超过1000个,如果总数量超过1000,需要分批发送

@@ -11,3 +11,3 @@ const qiniu = require("qiniu");

var bucketManager = new qiniu.rs.BucketManager(mac, config);
var bucket = 'if-pbl';
var bucket = proc.env.QINIU_TEST_BUCKET;
var key = 'qiniu.mp4';

@@ -14,0 +14,0 @@ var newMime = 'video/x-mp4';

@@ -11,3 +11,3 @@ const qiniu = require("qiniu");

var bucketManager = new qiniu.rs.BucketManager(mac, config);
var bucket = 'if-pbl';
var bucket = proc.env.QINIU_TEST_BUCKET;
var key = 'qiniu.mp4';

@@ -14,0 +14,0 @@ var newType = 1; //低频存储

@@ -11,5 +11,5 @@ const qiniu = require("qiniu");

var bucketManager = new qiniu.rs.BucketManager(mac, config);
var srcBucket = "if-pbl";
var bucket = proc.env.QINIU_TEST_BUCKET;
var srcKey = "qiniu.mp4";
var destBucket = "if-pbl";
var destBucket = srcBucket;
var destKey = "qiniu_new_copy.mp4";

@@ -16,0 +16,0 @@ var options = {

@@ -11,3 +11,3 @@ const qiniu = require("qiniu");

var bucketManager = new qiniu.rs.BucketManager(mac, config);
var bucket = "if-pbl";
var bucket = proc.env.QINIU_TEST_BUCKET;
var key = "qiniu_new_copy.mp4";

@@ -14,0 +14,0 @@ var days = 10;

@@ -11,3 +11,3 @@ const qiniu = require("qiniu");

var bucketManager = new qiniu.rs.BucketManager(mac, config);
var bucket = "if-pbl";
var bucket = proc.env.QINIU_TEST_BUCKET;
var key = "qiniu_new_copy.mp4";

@@ -14,0 +14,0 @@

@@ -12,3 +12,3 @@ const qiniu = require("qiniu");

var resUrl = 'http://devtools.qiniu.com/qiniu.png';
var bucket = "if-bc";
var bucket = proc.env.QINIU_TEST_BUCKET;
var key = "qiniu.png";

@@ -15,0 +15,0 @@

@@ -12,3 +12,3 @@ const qiniu = require("qiniu");

var bucket = 'if-pbl';
var bucket = proc.env.QINIU_TEST_BUCKET;
// @param options 列举操作的可选参数

@@ -15,0 +15,0 @@ // prefix 列举的文件前缀

@@ -11,5 +11,5 @@ const qiniu = require("qiniu");

var bucketManager = new qiniu.rs.BucketManager(mac, config);
var srcBucket = "if-pbl";
var srcBucket = proc.env.QINIU_TEST_BUCKET;
var srcKey = "qiniu.mp4";
var destBucket = "if-pbl";
var destBucket = srcBucket;
var destKey = "qiniu_new.mp4";

@@ -16,0 +16,0 @@ var options = {

@@ -11,3 +11,3 @@ const qiniu = require("qiniu");

var bucketManager = new qiniu.rs.BucketManager(mac, config);
var bucket = "if-bc";
var bucket = proc.env.QINIU_TEST_BUCKET;
var key = "qiniu.mp4";

@@ -14,0 +14,0 @@

@@ -11,3 +11,3 @@ const qiniu = require("qiniu");

var bucketManager = new qiniu.rs.BucketManager(mac, config);
var bucket = "if-pbl";
var bucket = proc.env.QINIU_TEST_BUCKET;
var key = "qiniux.mp4";

@@ -14,0 +14,0 @@

@@ -6,5 +6,6 @@ const qiniu = require("qiniu");

var secretKey = proc.env.QINIU_SECRET_KEY;
var bucket = proc.env.QINIU_TEST_BUCKET;
var mac = new qiniu.auth.digest.Mac(accessKey, secretKey);
var putPolicy = new qiniu.rs.PutPolicy({
scope: 'if-pbl'
scope: bucket
});

@@ -11,0 +12,0 @@

@@ -13,3 +13,3 @@ const qiniu = require("qiniu");

//处理指令集合
var saveBucket = 'if-bc';
var saveBucket = proc.env.QINIU_TEST_BUCKET;
var fops = [

@@ -16,0 +16,0 @@ 'avthumb/mp4/s/480x320/vb/150k|saveas/' + qiniu.util.urlsafeBase64Encode(

{
"name": "qiniu",
"version": "7.0.6",
"version": "7.0.7",
"description": "Node wrapper for Qiniu Resource (Cloud) Storage API",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -22,3 +22,3 @@ const fs = require('fs');

exports.RS_HOST = "http://rs.qiniu.com";
exports.RPC_TIMEOUT = 60000; //60s
exports.RPC_TIMEOUT = 120000; //120s

@@ -25,0 +25,0 @@ //proxy

@@ -31,6 +31,6 @@ const conf = require('../conf');

this.crc32 = crc32 || null;
this.checkCrc = checkCrc || 0;
this.checkCrc = checkCrc || 1;
}
FormUploader.prototype.putStream = function(uploadToken, key, rsStream,
FormUploader.prototype.putStream = function(uploadToken, key, fsStream,
putExtra, callbackFunc) {

@@ -43,6 +43,6 @@ putExtra = putExtra || new PutExtra();

if (!putExtra.fname) {
putExtra.fname = key ? key : '?';
putExtra.fname = key ? key : 'fname';
}
rsStream.on("error", function(err) {
fsStream.on("error", function(err) {
//callbackFunc

@@ -68,4 +68,6 @@ callbackFunc(err, null, null);

if (useCache) {
var postForm = createMultipartForm(uploadToken, key, rsStream, putExtra);
putReq(this.config, postForm, callbackFunc);
createMultipartForm(uploadToken, key, fsStream, putExtra, function(
postForm) {
putReq(that.config, postForm, callbackFunc);
});
} else {

@@ -84,5 +86,7 @@ zone.getZoneInfo(accessKey, bucket, function(err, cZoneInfo,

//req
var postForm = createMultipartForm(uploadToken, key, rsStream,
putExtra);
putReq(that.config, postForm, callbackFunc);
createMultipartForm(uploadToken, key, fsStream,
putExtra,
function(postForm) {
putReq(that.config, postForm, callbackFunc);
});
});

@@ -123,15 +127,8 @@ }

callbackFunc) {
var rsStream = new Readable();
rsStream.push(body);
rsStream.push(null);
var fsStream = new Readable();
fsStream.push(body);
fsStream.push(null);
putExtra = putExtra || new PutExtra();
if (putExtra.checkCrc == 1) {
var bodyCrc32 = getCrc32(body);
putExtra.crc32 = '' + parsStreameInt(bodyCrc32, 16);
} else if (putExtra.checkCrc == 2 && putExtra.crc32) {
putExtra.crc32 = '' + putExtra.crc32
}
return this.putStream(uploadToken, key, rsStream, putExtra, callbackFunc)
return this.putStream(uploadToken, key, fsStream, putExtra, callbackFunc)
}

@@ -144,3 +141,3 @@

function createMultipartForm(uploadToken, key, rsStream, putExtra) {
function createMultipartForm(uploadToken, key, fsStream, putExtra, callbackFunc) {
var postForm = formstream();

@@ -151,6 +148,3 @@ postForm.field('token', uploadToken);

}
postForm.stream('file', rsStream, putExtra.fname, putExtra.mimeType);
if (putExtra.crc32) {
postForm.field('crc32', putExtra.crc32);
}
postForm.stream('file', fsStream, putExtra.fname, putExtra.mimeType);

@@ -163,4 +157,13 @@ //putExtra params

}
var fileBody = [];
fsStream.on('data', function(data) {
fileBody.push(data);
});
return postForm;
fsStream.on('end', function() {
fileBody = Buffer.concat(fileBody);
var bodyCrc32 = parseInt("0x" + getCrc32(fileBody));
postForm.field('crc32', bodyCrc32);
});
callbackFunc(postForm);
}

@@ -178,11 +181,4 @@

putExtra = putExtra || new PutExtra();
var rsStream = fs.createReadStream(localFile);
var fsStream = fs.createReadStream(localFile);
if (putExtra.checkCrc == 1) {
var fileCrc32 = getCrc32(fs.readFileSync(localFile));
putExtra.crc32 = '' + parsStreameInt(fileCrc32, 16);
} else if (putExtra.checkCrc == 2 && putExtra.crc32) {
putExtra.crc32 = '' + putExtra.crc32
}
if (!putExtra.mimeType) {

@@ -196,3 +192,3 @@ putExtra.mimeType = mime.lookup(localFile);

return this.putStream(uploadToken, key, rsStream, putExtra, callbackFunc);
return this.putStream(uploadToken, key, fsStream, putExtra, callbackFunc);
}

@@ -199,0 +195,0 @@

@@ -8,2 +8,3 @@ const conf = require('../conf');

const fs = require('fs');
const getCrc32 = require('crc32');

@@ -161,3 +162,4 @@ exports.ResumeUploader = ResumeUploader;

respInfo) {
if (respInfo.statusCode != 200) {
var bodyCrc32 = parseInt("0x" + getCrc32(readData));
if (respInfo.statusCode != 200 || respBody.crc32 != bodyCrc32) {
callbackFunc(respErr, respBody, respInfo);

@@ -167,3 +169,2 @@ return;

finishedBlock += 1;
rsStream.resume();
var blkputRet = respBody;

@@ -182,2 +183,4 @@ finishedCtxList.push(blkputRet.ctx);

}
rsStream.resume();
}

@@ -184,0 +187,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc