use the backupdb config to determine bucket and prefix
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/* jslint node:true */
|
||||
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
@@ -81,12 +79,12 @@ function getSignedUploadUrl(backupConfig, filename, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getSignedDownloadUrl(backupConfig, filename, callback) {
|
||||
function getSignedDownloadUrl(backupConfig, info, callback) {
|
||||
assert.strictEqual(typeof backupConfig, 'object');
|
||||
assert.strictEqual(typeof filename, 'string');
|
||||
assert.strictEqual(typeof info, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
if (!backupConfig.bucket || !backupConfig.prefix) return new Error('Invalid configuration'); // prevent error in s3
|
||||
if (!info.bucket || !info.prefix) return new Error('Invalid configuration'); // prevent error in s3
|
||||
|
||||
getBackupCredentials(backupConfig, function (error, credentials) {
|
||||
if (error) return callback(error);
|
||||
@@ -94,8 +92,8 @@ function getSignedDownloadUrl(backupConfig, filename, callback) {
|
||||
var s3 = new AWS.S3(credentials);
|
||||
|
||||
var params = {
|
||||
Bucket: backupConfig.bucket,
|
||||
Key: backupConfig.prefix + '/' + filename,
|
||||
Bucket: info.bucket,
|
||||
Key: info.prefix + '/' + info.filename,
|
||||
Expires: 60 * 30 /* 30 minutes */
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user