New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

qiniu-js

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qiniu-js - npm Package Compare versions

Comparing version 3.3.3 to 3.4.0

coverage/lcov-report/utils/crc32.ts.html

4

esm/api/index.d.ts

@@ -37,3 +37,5 @@ import { Config, InternalConfig, UploadInfo } from '../upload';

*/
export declare function uploadChunk(token: string, key: string | null | undefined, index: number, uploadInfo: UploadInfo, options: Partial<utils.RequestOptions>): utils.Response<UploadChunkData>;
export declare function uploadChunk(token: string, key: string | null | undefined, index: number, uploadInfo: UploadInfo, options: Partial<utils.RequestOptions & {
md5: string;
}>): utils.Response<UploadChunkData>;
export declare type UploadCompleteData = any;

@@ -40,0 +42,0 @@ /**

@@ -92,3 +92,6 @@ var __assign = (this && this.__assign) || function () {

var url = getBaseUrl(bucket, key, uploadInfo) + ("/" + index);
return utils.request(url, __assign(__assign({}, options), { method: 'PUT', headers: utils.getHeadersForChunkUpload(token) }));
var headers = utils.getHeadersForChunkUpload(token);
if (options.md5)
headers['Content-MD5'] = options.md5;
return utils.request(url, __assign(__assign({}, options), { method: 'PUT', headers: headers }));
}

@@ -95,0 +98,0 @@ /**

@@ -27,2 +27,4 @@ import { QiniuError } from '../errors';

useCdnDomain: boolean;
/** 是否开启服务端校验 */
checkByServer: boolean;
/** 是否对分片进行 md5校验 */

@@ -29,0 +31,0 @@ checkByMD5: boolean;

@@ -50,2 +50,3 @@ var __extends = (this && this.__extends) || (function () {

};
import { CRC32 } from '../utils/crc32';
import { direct } from '../api';

@@ -60,3 +61,3 @@ import Base from './base';

return __awaiter(this, void 0, void 0, function () {
var formData, customVars_1, result;
var formData, crcSign, customVars_1, result;
var _this = this;

@@ -74,2 +75,9 @@ return __generator(this, function (_a) {

formData.append('fname', this.putExtra.fname);
if (!this.config.checkByServer) return [3 /*break*/, 2];
return [4 /*yield*/, CRC32.file(this.file)];
case 1:
crcSign = _a.sent();
formData.append('crc32', crcSign.toString());
_a.label = 2;
case 2:
if (this.putExtra.customVars) {

@@ -88,3 +96,3 @@ this.logger.info('init customVars.');

})];
case 1:
case 3:
result = _a.sent();

@@ -91,0 +99,0 @@ this.logger.info('Direct progress finish.');

@@ -162,2 +162,3 @@ var __extends = (this && this.__extends) || (function () {

body: chunk,
md5: this.config.checkByServer ? md5 : undefined,
onProgress: onProgress,

@@ -164,0 +165,0 @@ onCreate: function (xhr) { return _this.addXhr(xhr); }

@@ -47,3 +47,3 @@ var __assign = (this && this.__assign) || function () {

var _a = __assign({}, config), upprotocol = _a.upprotocol, uphost = _a.uphost, otherConfig = __rest(_a, ["upprotocol", "uphost"]);
var normalizeConfig = __assign({ uphost: [], retryCount: 3, checkByMD5: false, forceDirect: false, useCdnDomain: true, concurrentRequestLimit: 3, chunkSize: DEFAULT_CHUNK_SIZE, upprotocol: 'https', debugLogLevel: 'OFF', disableStatisticsReport: false }, otherConfig);
var normalizeConfig = __assign({ uphost: [], retryCount: 3, checkByMD5: false, forceDirect: false, useCdnDomain: true, checkByServer: false, concurrentRequestLimit: 3, chunkSize: DEFAULT_CHUNK_SIZE, upprotocol: 'https', debugLogLevel: 'OFF', disableStatisticsReport: false }, otherConfig);
// 兼容原来的 http: https: 的写法

@@ -50,0 +50,0 @@ if (upprotocol) {

@@ -11,2 +11,3 @@ import { DEFAULT_CHUNK_SIZE } from '../upload';

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -25,2 +26,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -40,2 +42,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -54,2 +57,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -69,2 +73,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -84,2 +89,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -86,0 +92,0 @@ useCdnDomain: false,

@@ -247,5 +247,7 @@ "use strict";

var url = getBaseUrl(bucket, key, uploadInfo) + ("/" + index);
var headers = utils.getHeadersForChunkUpload(token);
if (options.md5) headers['Content-MD5'] = options.md5;
return utils.request(url, __assign(__assign({}, options), {
method: 'PUT',
headers: utils.getHeadersForChunkUpload(token)
headers: headers
}));

@@ -252,0 +254,0 @@ }

@@ -25,2 +25,4 @@ "use strict";

var _crc = require("../utils/crc32");
var _api = require("../api");

@@ -210,3 +212,3 @@

return __awaiter(this, void 0, void 0, function () {
var formData, customVars_1, result;
var formData, crcSign, customVars_1, result;

@@ -228,3 +230,15 @@ var _this = this;

formData.append('fname', this.putExtra.fname);
if (!this.config.checkByServer) return [3
/*break*/
, 2];
return [4
/*yield*/
, _crc.CRC32.file(this.file)];
case 1:
crcSign = _a.sent();
formData.append('crc32', crcSign.toString());
_a.label = 2;
case 2:
if (this.putExtra.customVars) {

@@ -251,3 +265,3 @@ this.logger.info('init customVars.');

case 1:
case 3:
result = _a.sent();

@@ -254,0 +268,0 @@ this.logger.info('Direct progress finish.');

@@ -377,2 +377,3 @@ "use strict";

body: chunk,
md5: this.config.checkByServer ? md5 : undefined,
onProgress: onProgress,

@@ -379,0 +380,0 @@ onCreate: function onCreate(xhr) {

@@ -103,2 +103,3 @@ "use strict";

useCdnDomain: true,
checkByServer: false,
concurrentRequestLimit: 3,

@@ -105,0 +106,0 @@ chunkSize: _upload.DEFAULT_CHUNK_SIZE,

@@ -16,2 +16,3 @@ "use strict";

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -32,2 +33,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -49,2 +51,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -65,2 +68,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -83,2 +87,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -101,2 +106,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -103,0 +109,0 @@ useCdnDomain: false,

{
"name": "qiniu-js",
"jsName": "qiniu",
"version": "3.3.3",
"version": "3.4.0",
"private": false,

@@ -6,0 +6,0 @@ "description": "Javascript SDK for Qiniu Resource (Cloud) Storage AP",

@@ -218,3 +218,4 @@ # Qiniu-JavaScript-SDK

* config.concurrentRequestLimit: 分片上传的并发请求量,`number`,默认为3;因为浏览器本身也会限制最大并发量,所以最大并发量与浏览器有关。
* config.checkByMD5: 是否开启 MD5 校验,为布尔值;在断点续传时,开启 MD5 校验会将已上传的分片与当前分片进行 MD5 值比对,若不一致,则重传该分片,避免使用错误的分片。读取分片内容并计算 MD5 需要花费一定的时间,因此会稍微增加断点续传时的耗时,默认为 false,不开启。
* config.checkByServer: 是否开启服务端文件签名校验,为布尔值;开启后在文件上传时会计算本地的文件签名,服务端会根据本地的签名与接收到的数据的签名进行比对,如果不相同、则说明文件可能存在问题,此时会返回错误(`code`: 406),默认为 `false`,不开启。
* config.checkByMD5: 是否开启 `MD5` 校验,为布尔值;在断点续传时,开启 `MD5` 校验会将已上传的分片与当前分片进行 `MD5` 值比对,若不一致,则重传该分片,避免使用错误的分片。读取分片内容并计算 `MD5` 需要花费一定的时间,因此会稍微增加断点续传时的耗时,默认为 `false`,不开启。
* config.forceDirect: 是否上传全部采用直传方式,为布尔值;为 `true` 时则上传方式全部为直传 form 方式,禁用断点续传,默认 `false`。

@@ -221,0 +222,0 @@ * config.chunkSize: `number`,分片上传时每片的大小,必须为正整数,单位为 `MB`,且最大不能超过 1024,默认值 4。因为 chunk 数最大 10000,所以如果文件以你所设的 `chunkSize` 进行分片并且 chunk 数超过 10000,我们会把你所设的 `chunkSize` 扩大二倍,如果仍不符合则继续扩大,直到符合条件。

@@ -79,10 +79,13 @@ import { stringify } from 'querystring'

uploadInfo: UploadInfo,
options: Partial<utils.RequestOptions>
options: Partial<utils.RequestOptions & { md5: string }>
): utils.Response<UploadChunkData> {
const bucket = utils.getPutPolicy(token).bucketName
const url = getBaseUrl(bucket, key, uploadInfo) + `/${index}`
const headers = utils.getHeadersForChunkUpload(token)
if (options.md5) headers['Content-MD5'] = options.md5
return utils.request<UploadChunkData>(url, {
...options,
method: 'PUT',
headers: utils.getHeadersForChunkUpload(token)
headers
})

@@ -89,0 +92,0 @@ }

@@ -29,2 +29,4 @@ import { QiniuErrorName, QiniuError, QiniuRequestError } from '../errors'

useCdnDomain: boolean
/** 是否开启服务端校验 */
checkByServer: boolean
/** 是否对分片进行 md5校验 */

@@ -31,0 +33,0 @@ checkByMD5: boolean

@@ -0,1 +1,3 @@

import { CRC32 } from '../utils/crc32'
import { direct } from '../api'

@@ -18,2 +20,7 @@

if (this.config.checkByServer) {
const crcSign = await CRC32.file(this.file)
formData.append('crc32', crcSign.toString())
}
if (this.putExtra.customVars) {

@@ -20,0 +27,0 @@ this.logger.info('init customVars.')

@@ -156,2 +156,3 @@ import { uploadChunk, uploadComplete, initUploadParts, UploadChunkData } from '../api'

body: chunk,
md5: this.config.checkByServer ? md5 : undefined,
onProgress,

@@ -158,0 +159,0 @@ onCreate: (xhr: XMLHttpRequest) => this.addXhr(xhr)

@@ -12,2 +12,3 @@ import { DEFAULT_CHUNK_SIZE } from '../upload'

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -27,2 +28,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -43,2 +45,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -58,2 +61,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -74,2 +78,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -90,2 +95,3 @@ useCdnDomain: true,

checkByMD5: false,
checkByServer: false,
forceDirect: false,

@@ -92,0 +98,0 @@ useCdnDomain: false,

@@ -15,2 +15,3 @@ import Logger from '../logger'

useCdnDomain: true,
checkByServer: false,
concurrentRequestLimit: 3,

@@ -17,0 +18,0 @@ chunkSize: DEFAULT_CHUNK_SIZE,

@@ -5,2 +5,5 @@ $.ajax({url: "/api/uptoken", success: function(res){

var config = {
checkByServer: true,
checkByMD5: true,
forceDirect: false,
useCdnDomain: true,

@@ -7,0 +10,0 @@ disableStatisticsReport: false,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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