use the backupdb config to determine bucket and prefix

This commit is contained in:
Girish Ramakrishnan
2016-03-31 00:50:53 -07:00
parent f3a05931df
commit 39cc5d07d1
3 changed files with 23 additions and 23 deletions

View File

@@ -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 */
};