Pass through AWS/S3 specific options
This commit is contained in:
parent
00092b5129
commit
30e8ee0a09
|
@ -147,28 +147,21 @@ exports.upload = function(provider, req, res, options, cb) {
|
|||
uploadParams.acl = file.acl;
|
||||
}
|
||||
|
||||
// add AWS specific options
|
||||
// AWS specific options
|
||||
// See http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
|
||||
if (options.StorageClass) {
|
||||
uploadParams.StorageClass = options.StorageClass;
|
||||
}
|
||||
if (options.CacheControl) {
|
||||
uploadParams.CacheControl = options.CacheControl;
|
||||
}
|
||||
if (options.ServerSideEncryption) {
|
||||
uploadParams.ServerSideEncryption = options.ServerSideEncryption;
|
||||
}
|
||||
if (options.SSEKMSKeyId) {
|
||||
uploadParams.SSEKMSKeyId = options.SSEKMSKeyId;
|
||||
}
|
||||
if (options.SSECustomerAlgorithm) {
|
||||
uploadParams.SSECustomerAlgorithm = options.SSECustomerAlgorithm;
|
||||
}
|
||||
if (options.SSECustomerKey) {
|
||||
uploadParams.SSECustomerKey = options.SSECustomerKey;
|
||||
}
|
||||
if (options.SSECustomerKeyMD5) {
|
||||
uploadParams.SSECustomerKeyMD5 = options.SSECustomerKeyMD5;
|
||||
const awsOptionNames = [
|
||||
'StorageClass',
|
||||
'CacheControl',
|
||||
'ServerSideEncryption',
|
||||
'SSEKMSKeyId',
|
||||
'SSECustomerAlgorithm',
|
||||
'SSECustomerKey',
|
||||
'SSECustomerKeyMD5',
|
||||
];
|
||||
for (const awsOption of awsOptionNames) {
|
||||
if (typeof options[awsOption] !== 'undefined') {
|
||||
uploadParams[awsOption] = options[awsOption];
|
||||
}
|
||||
}
|
||||
|
||||
var writer = provider.upload(uploadParams);
|
||||
|
|
|
@ -54,6 +54,22 @@ function StorageService(options) {
|
|||
if (options.maxFieldsSize) {
|
||||
this.maxFieldsSize = options.maxFieldsSize;
|
||||
}
|
||||
// AWS specific options
|
||||
// See http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
|
||||
const awsOptionNames = [
|
||||
'StorageClass',
|
||||
'CacheControl',
|
||||
'ServerSideEncryption',
|
||||
'SSEKMSKeyId',
|
||||
'SSECustomerAlgorithm',
|
||||
'SSECustomerKey',
|
||||
'SSECustomerKeyMD5',
|
||||
];
|
||||
for (const awsOption of awsOptionNames) {
|
||||
if (typeof options[awsOption] !== 'undefined') {
|
||||
this[awsOption] = options[awsOption];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function map(obj) {
|
||||
|
@ -304,9 +320,28 @@ StorageService.prototype.upload = function(container, req, res, options, cb) {
|
|||
if (this.maxFieldsSize && !options.maxFieldsSize) {
|
||||
options.maxFieldsSize = this.maxFieldsSize;
|
||||
}
|
||||
|
||||
// AWS specific options
|
||||
// See http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
|
||||
const awsOptionNames = [
|
||||
'StorageClass',
|
||||
'CacheControl',
|
||||
'ServerSideEncryption',
|
||||
'SSEKMSKeyId',
|
||||
'SSECustomerAlgorithm',
|
||||
'SSECustomerKey',
|
||||
'SSECustomerKeyMD5',
|
||||
];
|
||||
for (const awsOption of awsOptionNames) {
|
||||
if (this[awsOption] && !options[awsOption]) {
|
||||
options[awsOption] = this[awsOption];
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof container === 'string') {
|
||||
options.container = container;
|
||||
}
|
||||
|
||||
debug('Upload configured with options %o', options);
|
||||
|
||||
handler.upload(this.client, req, res, options, cb);
|
||||
|
|
Loading…
Reference in New Issue