s3: Must encode copySource
https://github.com/aws/aws-sdk-js/issues/1302
This commit is contained in:
+2
-2
@@ -239,13 +239,13 @@ function copy(apiConfig, oldFilePath, newFilePath, callback) {
|
||||
var copyParams = {
|
||||
Bucket: apiConfig.bucket,
|
||||
Key: path.join(newFilePath, relativePath),
|
||||
CopySource: path.join(apiConfig.bucket, content.Key)
|
||||
CopySource: encodeURIComponent(path.join(apiConfig.bucket, content.Key)) // See aws-sdk-js/issues/1302
|
||||
};
|
||||
|
||||
progress.setDetail(progress.BACKUP, 'Copying ' + content.Key.slice(oldFilePath.length+1));
|
||||
|
||||
s3.copyObject(copyParams, function (error) {
|
||||
if (error && error.code === 'NoSuchKey') return iteratorCallback(new BackupsError(BackupsError.NOT_FOUND, `Old backup ${content.Key} not found`));
|
||||
if (error && error.code === 'NoSuchKey') return iteratorCallback(new BackupsError(BackupsError.NOT_FOUND, `Old backup not found: ${content.Key}`));
|
||||
if (error) {
|
||||
debug('copy: s3 copy error.', error);
|
||||
return iteratorCallback(new BackupsError(BackupsError.EXTERNAL_ERROR, `Error copying ${content.Key} : ${error.message}`));
|
||||
|
||||
@@ -252,12 +252,17 @@ describe('Storage', function () {
|
||||
});
|
||||
|
||||
it('can copy', function (done) {
|
||||
fs.writeFileSync(path.join(gS3Folder, 'uploadtest/C++.gitignore'), 'special', 'utf8');
|
||||
|
||||
var sourceKey = 'uploadtest';
|
||||
|
||||
s3.copy(gBackupConfig, sourceKey, 'uploadtest-copy', function (error) {
|
||||
var sourceFile = path.join(__dirname, 'storage/data/test.txt');
|
||||
expect(error).to.be(null);
|
||||
expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/test.txt')).size).to.be(fs.statSync(sourceFile).size);
|
||||
|
||||
expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/C++.gitignore')).size).to.be(7);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user