Comparing version 6.13.0 to 6.13.1
@@ -5,2 +5,9 @@ # Changelog | ||
### [6.13.1](https://github.com/aliyun/oss-nodejs-sdk/compare/v6.13.0...v6.13.1) (2021-01-07) | ||
### Bug Fixes | ||
* responseCacheControl in Node.js ([#919](https://github.com/aliyun/oss-nodejs-sdk/issues/919)) ([7ca7055](https://github.com/aliyun/oss-nodejs-sdk/commit/7ca7055a667604f3f653621b9f2974e28e9d2190)) | ||
## [6.13.0](https://github.com/aliyun/oss-nodejs-sdk/compare/v6.12.0...v6.13.0) (2021-01-06) | ||
@@ -7,0 +14,0 @@ |
@@ -6,3 +6,2 @@ // const debug = require('debug')('ali-oss:object'); | ||
const mime = require('mime'); | ||
const is = require('is-type-of'); | ||
const callback = require('../common/callback'); | ||
@@ -375,61 +374,1 @@ const merge = require('merge-descriptors'); | ||
}; | ||
/** | ||
* get | ||
* @param {String} name - object name | ||
* @param {String | Stream} file | ||
* @param {Object} options | ||
* @param {{res}} | ||
*/ | ||
proto.get = async function get(name, file, options = {}) { | ||
let writeStream = null; | ||
let needDestroy = false; | ||
if (is.writableStream(file)) { | ||
writeStream = file; | ||
} else if (is.string(file)) { | ||
writeStream = fs.createWriteStream(file); | ||
needDestroy = true; | ||
} else { | ||
// get(name, options) | ||
options = file; | ||
} | ||
options = options || {}; | ||
const responseCacheControl = options.responseCacheControl === null ? '' : 'no-cache'; | ||
options.subres = Object.assign( | ||
responseCacheControl ? { 'response-cache-control': responseCacheControl } : {}, | ||
options.subres | ||
); | ||
if (options.versionId) { | ||
options.subres.versionId = options.versionId; | ||
} | ||
if (options.process) { | ||
options.subres['x-oss-process'] = options.process; | ||
} | ||
let result; | ||
try { | ||
const params = this._objectRequestParams('GET', name, options); | ||
params.writeStream = writeStream; | ||
params.successStatuses = [200, 206, 304]; | ||
result = await this.request(params); | ||
if (needDestroy) { | ||
writeStream.destroy(); | ||
} | ||
} catch (err) { | ||
if (needDestroy) { | ||
writeStream.destroy(); | ||
// should delete the exists file before throw error | ||
await this._deleteFileSafe(file); | ||
} | ||
throw err; | ||
} | ||
return { | ||
res: result.res, | ||
content: result.data | ||
}; | ||
}; |
@@ -27,4 +27,8 @@ const fs = require('fs'); | ||
options = options || {}; | ||
const isBrowserEnv = process && process.browser; | ||
const responseCacheControl = options.responseCacheControl === null ? '' : 'no-cache'; | ||
const defaultSubresOptions = | ||
isBrowserEnv && responseCacheControl ? { 'response-cache-control': responseCacheControl } : {}; | ||
options.subres = Object.assign(defaultSubresOptions, options.subres); | ||
options.subres = Object.assign({ 'response-cache-control': 'no-cache' }, options.subres); | ||
if (options.versionId) { | ||
@@ -31,0 +35,0 @@ options.subres.versionId = options.versionId; |
@@ -27,3 +27,3 @@ "use strict"; | ||
if (isBuffer_1.isBuffer(value)) { | ||
return obj.slice(); | ||
return value.slice(); | ||
} | ||
@@ -30,0 +30,0 @@ const copy = Array.isArray(value) ? [] : {}; |
@@ -30,3 +30,3 @@ import { isBuffer } from './isBuffer'; | ||
if (isBuffer(value)) { | ||
return obj.slice(); | ||
return value.slice(); | ||
} | ||
@@ -33,0 +33,0 @@ |
{ | ||
"name": "ali-oss", | ||
"version": "6.13.0", | ||
"version": "6.13.1", | ||
"description": "aliyun oss(object storage service) node client", | ||
@@ -5,0 +5,0 @@ "main": "lib/client.js", |
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
2304738
43653