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 2.2.0 to 2.3.0

5

lib/conf.js

@@ -10,5 +10,8 @@ // ------------------------------------------------------------------------------------------

exports.PUT_TIMEOUT = 300000; // 300s = 5m
exports.BLOCK_SIZE = 1024*1024*4; // Block Size: 4MB
exports.CHUNK_SIZE = 1024*256; // Chunk Size: 256KB
exports.MAX_RETRY_TIMES = 3; // Max retry times: 3
exports.IO_HOST = 'http://iovip.qbox.me';
exports.FS_HOST = 'https://fs.qbox.me';
//exports.FS_HOST = 'https://fs.qbox.me';
exports.RS_HOST = 'http://rs.qbox.me';

@@ -15,0 +18,0 @@ exports.UP_HOST = 'http://up.qbox.me';

35

lib/digestauth.js

@@ -28,8 +28,3 @@ var crypto = require('crypto');

Client.prototype.auth = function(opt, params) {
opt.headers['Authorization'] = 'QBox ' + conf.ACCESS_KEY + ':' + checksum(opt, params);
};
Client.prototype.execute = function(url, params, onresp, onerror) {
Client.prototype.execute = function(options, url, params, onresp, onerror) {
var u = uri.parse(url);

@@ -53,2 +48,3 @@ var opt = {

var isStream = false;
var isText = true;
var contentLength = 0;

@@ -75,8 +71,14 @@ var contentType = 'application/x-www-form-urlencoded';

opt.headers['Content-Type'] = contentType;
if (contentLength !== null) {
opt.headers['Content-Type'] = contentType;
if (contentLength !== null) {
opt.headers['Content-Length'] = contentLength;
}
}
this.auth(opt, body);
if (options.UploadSignatureToken != undefined && options.UploadSignatureToken != null && options.UploadSignatureToken != "") {
opt.headers['Authorization'] = 'UpToken ' + options.UploadSignatureToken;
} else if (options.AccessToken != undefined && options.AccessToken != null && options.AccessToken != "") {
opt.headers['Authorization'] = 'Bearer ' + options.AccessToken;
} else {
opt.headers['Authorization'] = 'QBox ' + conf.ACCESS_KEY + ':' + checksum(opt, body);
}

@@ -98,3 +100,3 @@ var req = proto.request(opt, onresp);

Client.prototype.callWith = function(url, params, onret) {
Client.prototype._callWith = function(options, url, params, onret) {

@@ -135,5 +137,14 @@ var onresp = function(res) {

return this.execute(url, params, onresp, onerror);
return this.execute(options, url, params, onresp, onerror);
};
Client.prototype.callWith = function(url, params, onret) {
return this._callWith("", url, params, onret);
}
Client.prototype.callWithToken = function(uploadToken, url, params, onret){
var options = { 'UploadSignatureToken': uploadToken };
return this._callWith(options, url, params, onret);
};
exports.Client = Client;

@@ -140,0 +151,0 @@

@@ -120,9 +120,9 @@ var fs = require('fs');

Service.prototype.uploadWithToken = function(uploadToken, filename, stream, key, mimeType, customMeta, callbackParams, enableCrc32Check, onret) {
Service.prototype.uploadWithToken = function(uploadToken, localFile, stream, key, mimeType, customMeta, callbackParams, enableCrc32Check, onret) {
/*
* func UploadWithToken(uploadToken, filename, stream, bucket, key, mimeType, customMeta, callbackParams, enableCrc32Check, onret) => (data PutRet, code int, err Error)
* func UploadWithToken(uploadToken, localFile, stream, key, mimeType, customMeta, callbackParams, enableCrc32Check, onret) => (data PutRet, code int, err Error)
* 使用upload_token以multipart/form-data形式上传ReadStream流
**/
var bucket = this.bucket;
var actionString = util.generateActionString(filename, bucket, key, mimeType, customMeta, enableCrc32Check);
var actionString = util.generateActionString(localFile, bucket, key, mimeType, customMeta, enableCrc32Check);
if (callbackParams === null) {

@@ -138,4 +138,5 @@ callbackParams = {

var filename = path.basename(localFile);
var form = formstream();
var mimeType = mime.lookup(filename);
var mimeType = mime.lookup(localFile);
form.field('action', actionString);

@@ -148,3 +149,3 @@ form.field('params', callbackQueryString);

return this.conn.callWith(url, form, onret);
return this.conn.callWithToken(uploadToken, url, form, onret);
};

@@ -155,3 +156,3 @@

/*
* func UploadFileWithToken(uploadToken, localFile, bucket, key, mimeType, customMeta, callbackParams, enableCrc32Check, onret) => (data PutRet, code int, err Error)
* func UploadFileWithToken(uploadToken, localFile, key, mimeType, customMeta, callbackParams, enableCrc32Check, onret) => (data PutRet, code int, err Error)
* 使用upload_token以multipart/form-data形式上传文件

@@ -168,5 +169,4 @@ **/

}
var filename = path.basename(localFile);
var stream = fs.createReadStream(localFile);
self.uploadWithToken(uploadToken, filename, stream, key, mimeType, customMeta, callbackParams, enableCrc32Check, onret);
self.uploadWithToken(uploadToken, localFile, stream, key, mimeType, customMeta, callbackParams, enableCrc32Check, onret);
});

@@ -173,0 +173,0 @@ };

var fs = require('fs');
var mime = require('mime');
var crypto = require('crypto');
var crc32 = require('crc32');

@@ -36,2 +37,11 @@ // ------------------------------------------------------------------------------------------

}
if (enableCrc32Check) {
var fileStat = fs.statSync(localFile);
var fileSize = fileSize.size;
var buf = new Buffer(fileSize);
var fd = fs.open(localFile, 'r');
fs.readSync(fd, buf, 0, fileSize, 0);
var fileCrc32 = parseInt("0x" + crc32(buf)).toString();
actionParams += '/crc32/' + fileCrc32;
}
return actionParams;

@@ -48,3 +58,7 @@ }

}
total_params.join("&");
if (total_params.length > 0) {
return total_params.join("&");
} else {
return "";
}
}

@@ -102,3 +116,13 @@

exports.Form = Form;
// type Text
function Text(text, contentType) {
this.text = text;
this.contentType = contentType;
}
exports.Text = Text;
// ------------------------------------------------------------------------------------------
{
"name": "qiniu",
"version": "2.2.0",
"version": "2.3.0",
"description": "Node wrapper for Qiniu Resource (Cloud) Storage API",

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

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