Comparing version 6.7.0 to 6.8.0-beta
@@ -113,2 +113,5 @@ const debug = require('debug')('ali-oss'); | ||
// multiversion | ||
merge(proto, require('../common/bucket/putBucketVersioning')); | ||
merge(proto, require('../common/bucket/getBucketVersioning')); | ||
@@ -115,0 +118,0 @@ // multipart upload |
@@ -9,2 +9,4 @@ | ||
const copy = require('copy-to'); | ||
const isBlob = require('../common/utils/isBlob'); | ||
const isFile = require('../common/utils/isFile'); | ||
@@ -43,5 +45,5 @@ const proto = exports; | ||
if (!options.mime) { | ||
if (is.file(file)) { | ||
if (isFile(file)) { | ||
options.mime = mime.getType(path.extname(file.name)); | ||
} else if (is.blob(file)) { | ||
} else if (isBlob(file)) { | ||
options.mime = file.type; | ||
@@ -207,11 +209,2 @@ } else { | ||
is.file = function file(obj) { | ||
return typeof (File) !== 'undefined' && obj instanceof File; | ||
}; | ||
is.blob = function (blob) { | ||
return typeof (Blob) !== 'undefined' && blob instanceof Blob; | ||
}; | ||
/** | ||
@@ -223,3 +216,3 @@ * Get file size | ||
return file.length; | ||
} else if (is.blob(file) || is.file(file)) { | ||
} else if (isBlob(file) || isFile(file)) { | ||
return file.size; | ||
@@ -297,3 +290,3 @@ } if (is.string(file)) { | ||
proto._createStream = function _createStream(file, start, end) { | ||
if (is.blob(file) || is.file(file)) { | ||
if (isBlob(file) || isFile(file)) { | ||
return new WebFileReadStream(file.slice(start, end)); | ||
@@ -321,3 +314,3 @@ } | ||
Math.ceil(fileSize / maxNumParts), | ||
partSize, | ||
partSize | ||
); | ||
@@ -324,0 +317,0 @@ }; |
@@ -13,2 +13,4 @@ | ||
const merge = require('merge-descriptors'); | ||
const isBlob = require('../common/utils/isBlob'); | ||
const isFile = require('../common/utils/isFile'); | ||
@@ -68,5 +70,5 @@ // var assert = require('assert'); | ||
content = file; | ||
} else if (is.blob(file) || is.file(file)) { | ||
} else if (isBlob(file) || isFile(file)) { | ||
if (!options.mime) { | ||
if (is.file(file)) { | ||
if (isFile(file)) { | ||
options.mime = mime.getType(path.extname(file.name)); | ||
@@ -90,3 +92,3 @@ } else { | ||
} else { | ||
throw new TypeError('Must provide Buffer/Blob for put.'); | ||
throw new TypeError('Must provide Buffer/Blob/File for put.'); | ||
} | ||
@@ -243,39 +245,2 @@ | ||
proto.deleteMulti = async function deleteMulti(names, options) { | ||
options = options || {}; | ||
let xml = '<?xml version="1.0" encoding="UTF-8"?>\n<Delete>\n'; | ||
if (options.quiet) { | ||
xml += ' <Quiet>true</Quiet>\n'; | ||
} else { | ||
xml += ' <Quiet>false</Quiet>\n'; | ||
} | ||
for (let i = 0; i < names.length; i++) { | ||
xml += ` <Object><Key>${ | ||
utility.escape(this._objectName(names[i]))}</Key></Object>\n`; | ||
} | ||
xml += '</Delete>'; | ||
this.debug('delete multi objects: %s', xml, 'info'); | ||
options.subres = 'delete'; | ||
const params = this._objectRequestParams('POST', '', options); | ||
params.mime = 'xml'; | ||
params.content = xml; | ||
params.xmlResponse = true; | ||
params.successStatuses = [200]; | ||
const result = await this.request(params); | ||
const r = result.data; | ||
let deleted = (r && r.Deleted) || null; | ||
if (deleted) { | ||
if (!Array.isArray(deleted)) { | ||
deleted = [deleted]; | ||
} | ||
deleted = deleted.map(item => item.Key); | ||
} | ||
return { | ||
res: result.res, | ||
deleted | ||
}; | ||
}; | ||
merge(proto, require('../common/object/copyObject')); | ||
@@ -286,2 +251,5 @@ merge(proto, require('../common/object/getObjectTagging')); | ||
merge(proto, require('../common/image')); | ||
merge(proto, require('../common/object/getBucketVersions')); | ||
merge(proto, require('../common/object/getACL')); | ||
merge(proto, require('../common/object/putACL')); | ||
@@ -342,52 +310,2 @@ proto.putMeta = async function putMeta(name, meta, options) { | ||
/* | ||
* Set object's ACL | ||
* @param {String} name the object key | ||
* @param {String} acl the object ACL | ||
* @param {Object} options | ||
*/ | ||
proto.putACL = async function putACL(name, acl, options) { | ||
options = options || {}; | ||
options.subres = 'acl'; | ||
options.headers = options.headers || {}; | ||
options.headers['x-oss-object-acl'] = acl; | ||
name = this._objectName(name); | ||
const params = this._objectRequestParams('PUT', name, options); | ||
params.successStatuses = [200]; | ||
const result = await this.request(params); | ||
return { | ||
res: result.res | ||
}; | ||
}; | ||
/* | ||
* Get object's ACL | ||
* @param {String} name the object key | ||
* @param {Object} options | ||
* @return {Object} | ||
*/ | ||
proto.getACL = async function getACL(name, options) { | ||
options = options || {}; | ||
options.subres = 'acl'; | ||
name = this._objectName(name); | ||
const params = this._objectRequestParams('GET', name, options); | ||
params.successStatuses = [200]; | ||
params.xmlResponse = true; | ||
const result = await this.request(params); | ||
return { | ||
acl: result.data.AccessControlList.Grant, | ||
owner: { | ||
id: result.data.Owner.ID, | ||
displayName: result.data.Owner.DisplayName | ||
}, | ||
res: result.res | ||
}; | ||
}; | ||
/** | ||
@@ -401,3 +319,3 @@ * Restore Object | ||
options = options || {}; | ||
options.subres = 'restore'; | ||
options.subres = Object.assign({ restore: '' }, options.subres); | ||
const params = this._objectRequestParams('POST', name, options); | ||
@@ -404,0 +322,0 @@ params.successStatuses = [202]; |
@@ -1,1 +0,1 @@ | ||
exports.version="6.7.0" | ||
exports.version="6.8.0-beta" |
@@ -23,1 +23,3 @@ const merge = require('merge-descriptors'); | ||
merge(proto, require('./deleteBucketPolicy')); | ||
merge(proto, require('./getBucketVersioning')); | ||
merge(proto, require('./putBucketVersioning')); |
@@ -104,3 +104,7 @@ /* eslint-disable no-use-before-define */ | ||
if (rule.expiration) { | ||
checkDaysAndDate(rule.expiration, 'Expiration'); | ||
if (!rule.expiration.expiredObjectDeleteMarker) { | ||
checkDaysAndDate(rule.expiration, 'Expiration'); | ||
} else if (rule.expiration.days || rule.expiration.createdBeforeDate) { | ||
throw new Error('expiredObjectDeleteMarker cannot be used with days or createdBeforeDate'); | ||
} | ||
} | ||
@@ -112,4 +116,4 @@ | ||
if (!rule.expiration && !rule.abortMultipartUpload && !rule.transition) { | ||
throw new Error('Rule must includes expiration or abortMultipartUpload or transition'); | ||
if (!rule.expiration && !rule.abortMultipartUpload && !rule.transition && !rule.noncurrentVersionTransition) { | ||
throw new Error('Rule must includes expiration or abortMultipartUpload or transition or noncurrentVersionTransition'); | ||
} | ||
@@ -116,0 +120,0 @@ |
@@ -8,3 +8,3 @@ const _checkBucketName = require('../utils/checkBucketName'); | ||
* putBucketTags | ||
* @param {Sting} name - bucket name | ||
* @param {String} name - bucket name | ||
* @param {Object} tag - bucket tag, eg: `{a: "1", b: "2"}` | ||
@@ -11,0 +11,0 @@ * @param {Object} options |
@@ -21,6 +21,12 @@ | ||
/* eslint max-len: [0] */ | ||
proto.uploadPartCopy = async function uploadPartCopy(name, uploadId, partNo, range, sourceData, options) { | ||
options = options || {}; | ||
proto.uploadPartCopy = async function uploadPartCopy(name, uploadId, partNo, range, sourceData, options = {}) { | ||
options.headers = options.headers || {}; | ||
const copySource = `/${sourceData.sourceBucketName}/${encodeURIComponent(sourceData.sourceKey)}`; | ||
const versionId = options.versionId || (options.subres && options.subres.versionId) || null; | ||
let copySource; | ||
if (versionId) { | ||
copySource = `/${sourceData.sourceBucketName}/${encodeURIComponent(sourceData.sourceKey)}?versionId=${versionId}`; | ||
} else { | ||
copySource = `/${sourceData.sourceBucketName}/${encodeURIComponent(sourceData.sourceKey)}`; | ||
} | ||
options.headers['x-oss-copy-source'] = copySource; | ||
@@ -58,6 +64,6 @@ if (range) { | ||
*/ | ||
proto.multipartUploadCopy = async function multipartUploadCopy(name, sourceData, options) { | ||
proto.multipartUploadCopy = async function multipartUploadCopy(name, sourceData, options = {}) { | ||
this.resetCancelFlag(); | ||
options = options || {}; | ||
const objectMeta = await this._getObjectMeta(sourceData.sourceBucketName, sourceData.sourceKey, {}); | ||
const { metaOpt = {} } = options; | ||
const objectMeta = await this._getObjectMeta(sourceData.sourceBucketName, sourceData.sourceKey, metaOpt); | ||
const fileSize = objectMeta.res.headers['content-length']; | ||
@@ -125,2 +131,5 @@ sourceData.startOffset = sourceData.startOffset || 0; | ||
} | ||
if (options.metaOpt) { | ||
copy(options.metaOpt).to(uploadPartCopyOptions); | ||
} | ||
@@ -127,0 +136,0 @@ const uploadPartJob = function uploadPartJob(self, partNo, source) { |
@@ -57,4 +57,6 @@ const _checkBucketName = require('../utils/checkBucketName'); | ||
sourceName = `/${bucketName}/${encodeURIComponent(sourceName)}`; | ||
sourceName = encodeURI(sourceName); | ||
sourceName = `/${bucketName}/${sourceName}`; | ||
return sourceName; | ||
}; |
@@ -12,3 +12,3 @@ const proto = exports; | ||
) { | ||
options.subres = 'tagging'; | ||
options.subres = Object.assign({ tagging: '' }, options.subres); | ||
name = this._objectName(name); | ||
@@ -15,0 +15,0 @@ const params = this._objectRequestParams('DELETE', name, options); |
@@ -12,3 +12,3 @@ const proto = exports; | ||
name = this._objectName(name); | ||
options.subres = 'objectMeta'; | ||
options.subres = Object.assign({ objectMeta: '' }, options.subres); | ||
const params = this._objectRequestParams('HEAD', name, options); | ||
@@ -15,0 +15,0 @@ params.successStatuses = [200]; |
@@ -11,3 +11,3 @@ const proto = exports; | ||
proto.getObjectTagging = async function getObjectTagging(name, options = {}) { | ||
options.subres = 'tagging'; | ||
options.subres = Object.assign({ tagging: '' }, options.subres); | ||
name = this._objectName(name); | ||
@@ -14,0 +14,0 @@ const params = this._objectRequestParams('GET', name, options); |
@@ -9,5 +9,4 @@ const proto = exports; | ||
proto.getSymlink = async function getSymlink(name, options) { | ||
options = options || {}; | ||
options.subres = 'symlink'; | ||
proto.getSymlink = async function getSymlink(name, options = {}) { | ||
options.subres = Object.assign({ symlink: '' }, options.subres); | ||
name = this._objectName(name); | ||
@@ -14,0 +13,0 @@ const params = this._objectRequestParams('GET', name, options); |
@@ -13,2 +13,6 @@ const merge = require('merge-descriptors'); | ||
merge(proto, require('./deleteObjectTagging')); | ||
merge(proto, require('./getBucketVersions')); | ||
merge(proto, require('./deleteMulti')); | ||
merge(proto, require('./getACL')); | ||
merge(proto, require('./putACL')); | ||
@@ -7,3 +7,3 @@ const obj2xml = require('../utils/obj2xml'); | ||
* putObjectTagging | ||
* @param {Sting} name - object name | ||
* @param {String} name - object name | ||
* @param {Object} tag - object tag, eg: `{a: "1", b: "2"}` | ||
@@ -16,3 +16,3 @@ * @param {Object} options | ||
options.subres = 'tagging'; | ||
options.subres = Object.assign({ tagging: '' }, options.subres); | ||
name = this._objectName(name); | ||
@@ -19,0 +19,0 @@ const params = this._objectRequestParams('PUT', name, options); |
const proto = exports; | ||
/** | ||
* putSymlink | ||
* @param {Sting} name - object name | ||
* @param {String} name - object name | ||
* @param {String} targetName - target name | ||
@@ -16,3 +16,3 @@ * @param {Object} options | ||
options.headers['x-oss-symlink-target'] = targetName; | ||
options.subres = 'symlink'; | ||
options.subres = Object.assign({ symlink: '' }, options.subres); | ||
@@ -19,0 +19,0 @@ if (options.storageClass) { |
@@ -7,2 +7,3 @@ | ||
const mime = require('mime'); | ||
const isFile = require('./common/utils/isFile'); | ||
@@ -39,3 +40,3 @@ const proto = exports; | ||
const minPartSize = 100 * 1024; | ||
const filename = is.file(file) ? file.name : file; | ||
const filename = isFile(file) ? file.name : file; | ||
options.mime = options.mime || mime.lookup(path.extname(filename)); | ||
@@ -178,7 +179,2 @@ options.headers = options.headers || {}; | ||
is.file = function (file) { | ||
return typeof (File) !== 'undefined' && file instanceof File; | ||
}; | ||
/** | ||
@@ -190,3 +186,3 @@ * Get file size | ||
return file.length; | ||
} else if (is.file(file)) { | ||
} else if (isFile(file)) { | ||
return file.size; | ||
@@ -264,3 +260,3 @@ } if (is.string(file)) { | ||
proto._createStream = function _createStream(file, start, end) { | ||
if (is.file(file)) { | ||
if (isFile(file)) { | ||
return new WebFileReadStream(file.slice(start, end)); | ||
@@ -267,0 +263,0 @@ } else if (is.string(file)) { |
@@ -256,39 +256,2 @@ | ||
proto.deleteMulti = async function deleteMulti(names, options) { | ||
options = options || {}; | ||
let xml = '<?xml version="1.0" encoding="UTF-8"?>\n<Delete>\n'; | ||
if (options.quiet) { | ||
xml += ' <Quiet>true</Quiet>\n'; | ||
} else { | ||
xml += ' <Quiet>false</Quiet>\n'; | ||
} | ||
for (let i = 0; i < names.length; i++) { | ||
xml += ` <Object><Key>${ | ||
utility.escape(this._objectName(names[i]))}</Key></Object>\n`; | ||
} | ||
xml += '</Delete>'; | ||
debug('delete multi objects: %s', xml); | ||
options.subres = 'delete'; | ||
const params = this._objectRequestParams('POST', '', options); | ||
params.mime = 'xml'; | ||
params.content = xml; | ||
params.xmlResponse = true; | ||
params.successStatuses = [200]; | ||
const result = await this.request(params); | ||
const r = result.data; | ||
let deleted = (r && r.Deleted) || null; | ||
if (deleted) { | ||
if (!Array.isArray(deleted)) { | ||
deleted = [deleted]; | ||
} | ||
deleted = deleted.map(item => item.Key); | ||
} | ||
return { | ||
res: result.res, | ||
deleted | ||
}; | ||
}; | ||
proto.putMeta = async function putMeta(name, meta, options) { | ||
@@ -347,52 +310,2 @@ return await this.copy(name, name, { | ||
/* | ||
* Set object's ACL | ||
* @param {String} name the object key | ||
* @param {String} acl the object ACL | ||
* @param {Object} options | ||
*/ | ||
proto.putACL = async function putACL(name, acl, options) { | ||
options = options || {}; | ||
options.subres = 'acl'; | ||
options.headers = options.headers || {}; | ||
options.headers['x-oss-object-acl'] = acl; | ||
name = this._objectName(name); | ||
const params = this._objectRequestParams('PUT', name, options); | ||
params.successStatuses = [200]; | ||
const result = await this.request(params); | ||
return { | ||
res: result.res | ||
}; | ||
}; | ||
/* | ||
* Get object's ACL | ||
* @param {String} name the object key | ||
* @param {Object} options | ||
* @return {Object} | ||
*/ | ||
proto.getACL = async function getACL(name, options) { | ||
options = options || {}; | ||
options.subres = 'acl'; | ||
name = this._objectName(name); | ||
const params = this._objectRequestParams('GET', name, options); | ||
params.successStatuses = [200]; | ||
params.xmlResponse = true; | ||
const result = await this.request(params); | ||
return { | ||
acl: result.data.AccessControlList.Grant, | ||
owner: { | ||
id: result.data.Owner.ID, | ||
displayName: result.data.Owner.DisplayName | ||
}, | ||
res: result.res | ||
}; | ||
}; | ||
/** | ||
@@ -406,3 +319,3 @@ * Restore Object | ||
options = options || {}; | ||
options.subres = 'restore'; | ||
options.subres = Object.assign({ restore: '' }, options.subres); | ||
const params = this._objectRequestParams('POST', name, options); | ||
@@ -420,3 +333,3 @@ params.successStatuses = [202]; | ||
* putSymlink | ||
* @param {Sting} name - object name | ||
* @param {String} name - object name | ||
* @param {String} targetName - target name | ||
@@ -423,0 +336,0 @@ * @param {Object} options |
{ | ||
"name": "ali-oss", | ||
"version": "6.7.0", | ||
"version": "6.8.0-beta", | ||
"description": "aliyun oss(object storage service) node client", | ||
@@ -5,0 +5,0 @@ "main": "lib/client.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1866644
84
36019
3759
2