Comparing version 4.1.4 to 4.1.5
4.1.5 / 2016-03-02 | ||
================== | ||
* add README for multipart | ||
* provide checkpoint in multipart upload progress | ||
* allow more HTTP methods in signatureUrl | ||
* allow config expires in signatureUrl | ||
* ignore image-client coverage | ||
* stop check leaks in test, work around #74 | ||
* chore(package): update urllib to version 2.8.0 | ||
* fix post-release | ||
4.1.4 / 2016-01-28 | ||
@@ -3,0 +15,0 @@ ================== |
@@ -15,2 +15,3 @@ /** | ||
/* istanbul ignore next */ | ||
module.exports = function (OssClient) { | ||
@@ -141,2 +142,3 @@ | ||
/* istanbul ignore next */ | ||
function objectRequestParams(method, name, options) { | ||
@@ -143,0 +145,0 @@ options = options || {}; |
@@ -37,5 +37,8 @@ /**! | ||
proto.multipartUpload = function* (name, file, options) { | ||
options = options || {}; | ||
if (options.checkpoint && options.checkpoint.uploadId) { | ||
return yield this._resumeMultipart(options.checkpoint, options); | ||
} | ||
var minPartSize = 100 * 1024; | ||
options = options || {}; | ||
var filename = is.file(file) ? file.name : file; | ||
@@ -65,21 +68,49 @@ options.mime = options.mime || mime.lookup(path.extname(filename)); | ||
var uploadId = result.uploadId; | ||
var partSize = this._getPartSize(fileSize, options.partSize); | ||
var partSize = this._getPartSize(fileSize, options.partSize); | ||
var checkpoint = { | ||
file: file, | ||
name: name, | ||
fileSize: fileSize, | ||
partSize: partSize, | ||
uploadId: uploadId, | ||
doneParts: [], | ||
nextPart: 0 | ||
}; | ||
return yield this._resumeMultipart(checkpoint, options); | ||
}; | ||
/* | ||
* Resume multipart upload from checkpoint. The checkpoint will be | ||
* updated after each successful part upload. | ||
* @param {Object} checkpoint the checkpoint | ||
* @param {Object} options | ||
*/ | ||
proto._resumeMultipart = function* (checkpoint, options) { | ||
var file = checkpoint.file; | ||
var fileSize = checkpoint.fileSize; | ||
var partSize = checkpoint.partSize; | ||
var uploadId = checkpoint.uploadId; | ||
var doneParts = checkpoint.doneParts; | ||
var nextPart = checkpoint.nextPart; | ||
var name = checkpoint.name; | ||
var partDatas = this._divideParts(file, fileSize, partSize); | ||
var numParts = partDatas.length; | ||
var parts = []; | ||
for (var i = 0; i < numParts; i++) { | ||
for (var i = nextPart; i < numParts; i++) { | ||
var partNo = i + 1; | ||
var result = yield this._uploadPart(name, uploadId, partNo, partDatas[i]); | ||
parts.push({ | ||
doneParts.push({ | ||
number: partNo, | ||
etag: result.res.headers.etag | ||
}); | ||
checkpoint.nextPart = i + 1; | ||
if (options && options.progress) { | ||
yield options.progress(partNo / numParts); | ||
yield options.progress(partNo / numParts, checkpoint); | ||
} | ||
} | ||
return yield this._completeMultipartUpload(name, uploadId, parts, options); | ||
return yield this._completeMultipartUpload(name, uploadId, doneParts, options); | ||
}; | ||
@@ -86,0 +117,0 @@ |
@@ -391,3 +391,4 @@ /**! | ||
}; | ||
var expires = utility.timestamp() + 1800; | ||
options = options || {}; | ||
var expires = utility.timestamp() + (options.expires || 1800); | ||
var resource = this._getResource(params); | ||
@@ -397,6 +398,6 @@ | ||
var signList = []; | ||
for (var k in options) { | ||
for (var k in options.response) { | ||
var key = 'response-' + k.toLowerCase(); | ||
query[key] = options[k]; | ||
signList.push(key + '=' + options[k]); | ||
query[key] = options.response[k]; | ||
signList.push(key + '=' + options.response[k]); | ||
} | ||
@@ -413,5 +414,5 @@ if (this.options.stsToken) { | ||
var stringToSign = [ | ||
'GET', | ||
'', // Content-MD5 | ||
'', // Content-Type | ||
options.method || 'GET', | ||
options['content-md5'] || '', // Content-MD5 | ||
options['content-type'] || '', // Content-Type | ||
expires, | ||
@@ -418,0 +419,0 @@ resource |
{ | ||
"name": "ali-oss", | ||
"version": "4.1.4", | ||
"version": "4.1.5", | ||
"description": "aliyun oss(open storage service) node client", | ||
@@ -10,4 +10,4 @@ "main": "lib/client.js", | ||
"scripts": { | ||
"test": "mocha --check-leaks -t 30000 -r thunk-mocha -r should test/*.test.js", | ||
"test-cov": "istanbul cover node_modules/.bin/_mocha -- -R dot --check-leaks -t 60000 -r thunk-mocha -r should test/*.test.js", | ||
"test": "mocha -t 30000 -r thunk-mocha -r should test/*.test.js", | ||
"test-cov": "istanbul cover node_modules/.bin/_mocha -- -R dot -t 60000 -r thunk-mocha -r should test/*.test.js", | ||
"jshint": "jshint .", | ||
@@ -20,3 +20,6 @@ "autod": "autod", | ||
"pre-release": "npm run build-dist", | ||
"post-release": "npm publish && npm run publish-to-cdn" | ||
"post-release": [ | ||
"npm publish", | ||
"npm run publish-to-cdn" | ||
] | ||
}, | ||
@@ -75,3 +78,3 @@ "repository": { | ||
"sdk-base": "~1.1.0", | ||
"urllib": "~2.7.0", | ||
"urllib": "~2.8.0", | ||
"utility": "~1.6.0", | ||
@@ -78,0 +81,0 @@ "xml2js": "~0.4.16" |
129
README.md
@@ -76,5 +76,8 @@ oss-nodejs-sdk | ||
- [.deleteMulti*(names[, options])](#deletemultinames-options) | ||
- [.signatureUrl(name)](#signatureurlname) | ||
- [.signatureUrl(name[, options])](#signatureurlname-options) | ||
- [.putACL*(name, acl[, options])](#putaclname-acl-options) | ||
- [.getACL*(name[, options])](#getaclname-options) | ||
- [.multipartUpload*(name, file[, options])](#multipartuploadname-file-options) | ||
- [.listUploads*(query[, options])](#listuploadsquery-options) | ||
- [.abortMultipartUpload*(name, uploadId[, options])](#abortmultipartuploadname-uploadid-options) | ||
- [Create A Image Service Instance](#create-a-image-service-instance) | ||
@@ -1243,5 +1246,5 @@ - [#oss.ImageClient(options)](#ossimageclientoptions) | ||
### .signatureUrl(name) | ||
### .signatureUrl(name[, options]) | ||
Create a signature url for directly download. | ||
Create a signature url for download or upload object. | ||
@@ -1253,3 +1256,8 @@ parameters: | ||
- [expires] {Number} after expires seconds, the url will become invalid, default is `1800` | ||
- [timeout] {Number} the operation timeout | ||
- [method] {String} the HTTP method, default is 'GET' | ||
- [response] {Object} set the response headers for download | ||
- [content-type] {String} set the response content type | ||
- [content-disposition] {String} set the response content disposition | ||
- [cache-control] {String} set the response cache control | ||
- See more: https://help.aliyun.com/document_detail/oss/api-reference/object/GetObject.html | ||
@@ -1260,3 +1268,3 @@ Success will return signature url. | ||
- Get an object signature url for download | ||
- Get signature url for object | ||
@@ -1266,2 +1274,17 @@ ```js | ||
console.log(url); | ||
var url = store.signatureUrl('ossdemo.txt', { | ||
expires: 3600, | ||
method: 'PUT' | ||
}); | ||
console.log(url); | ||
var url = store.signatureUrl('ossdemo.txt', { | ||
expires: 3600, | ||
response: { | ||
'content-type': 'text/custom', | ||
'content-disposition': 'attachment' | ||
} | ||
}); | ||
console.log(url); | ||
``` | ||
@@ -1324,2 +1347,97 @@ | ||
### .multipartUpload*(name, file[, options) | ||
Upload file with [OSS multipart][oss-multipart]. | ||
parameters: | ||
- name {String} object name | ||
- file {String|File} file path or HTML5 Web File | ||
- [options] {Object} optional args | ||
- [partSize] {Number} the suggested size for each part | ||
- [progress] {Function} the progress callback called after each | ||
successful upload of one part, it will be given two parameters: | ||
(percentage {Number}, checkpoint {Object}) | ||
- [checkpoint] {Object} the checkpoint to resume upload, if this is | ||
provided, it will continue the upload from where interrupted, | ||
otherwise a new multipart upload will be created. | ||
example: | ||
- Upload using multipart | ||
```js | ||
var result = yield store.multipartUpload('object', '/tmp/file'); | ||
console.log(result); | ||
var result = yield store.multipartUpload('object', '/tmp/file', { | ||
partSize: 1024 * 1024, | ||
progress: function* (p, cpt) { | ||
console.log(p); | ||
console.log(cpt); | ||
} | ||
}); | ||
var result = yield store.multipartUpload('object', '/tmp/file', { | ||
checkpoint: savedCpt, | ||
progress: function* (p, cpt) { | ||
console.log(p); | ||
console.log(cpt); | ||
} | ||
}); | ||
``` | ||
### .listUploads*(query[, options]) | ||
List on-going multipart uploads, i.e.: those not completed and not | ||
aborted. | ||
parameters: | ||
- query {Object} query parameters | ||
- [prefix] {String} the object key prefix | ||
- [max-uploads] {Number} the max uploads to return | ||
- [key-marker] {String} the object key marker, if `upload-id-marker` | ||
is not provided, return uploads with `key > marker`, otherwise | ||
return uploads with `key >= marker && uploadId > id-marker` | ||
- [upload-id-marker] {String} the upload id marker, must be used | ||
**WITH** `key-marker` | ||
- [options] {Object} optional args | ||
- [timeout] {Number} the operation timeout | ||
example: | ||
- List on-going multipart uploads | ||
```js | ||
var result = yield store.listUploads({ | ||
'max-uploads': 100, | ||
'key-marker': 'my-object', | ||
'upload-id-marker': 'upload-id' | ||
}); | ||
console.log(result); | ||
``` | ||
### .abortMultipartUpload*(name, uploadId[, options]) | ||
Abort a multipart upload for object. | ||
parameters: | ||
- name {String} the object name | ||
- uploadId {String} the upload id | ||
- [options] {Object} optional args | ||
- [timeout] {Number} the operation timeout | ||
example: | ||
- Abort a multipart upload | ||
```js | ||
var result = yield store.abortMultipartUpload('object', 'upload-id'); | ||
console.log(result); | ||
``` | ||
## Create A Image Service Instance | ||
@@ -1948,1 +2066,2 @@ | ||
[browser-sample]: https://github.com/rockuw/oss-in-browser | ||
[oss-multipart]: https://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/InitiateMultipartUpload.html |
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
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
127851
1922
2061
+ Addedurllib@2.8.0(transitive)
- Removedurllib@2.7.3(transitive)
Updatedurllib@~2.8.0