Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S3 copyObject usage - Missing bucket name #3745

Merged
merged 4 commits into from
Mar 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions server/modules/storage/s3/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const getFilePath = (page, pathKey) => {
module.exports = class S3CompatibleStorage {
constructor(storageName) {
this.storageName = storageName
this.bucketName;
MaXeraph marked this conversation as resolved.
Show resolved Hide resolved
}
async activated() {
// not used
Expand All @@ -32,6 +33,7 @@ module.exports = class S3CompatibleStorage {
async init() {
WIKI.logger.info(`(STORAGE/${this.storageName}) Initializing...`)
const { accessKeyId, secretAccessKey, bucket } = this.config
this.bucketName = bucket;
MaXeraph marked this conversation as resolved.
Show resolved Hide resolved
const s3Config = {
accessKeyId,
secretAccessKey,
Expand Down Expand Up @@ -89,7 +91,8 @@ module.exports = class S3CompatibleStorage {
destinationFilePath = `${page.destinationLocaleCode}/${destinationFilePath}`
}
}
await this.s3.copyObject({ CopySource: sourceFilePath, Key: destinationFilePath }).promise()

await this.s3.copyObject({ CopySource: `${this.bucketName}/${sourceFilePath}`, Key: destinationFilePath }).promise()
await this.s3.deleteObject({ Key: sourceFilePath }).promise()
}
/**
Expand Down Expand Up @@ -117,7 +120,7 @@ module.exports = class S3CompatibleStorage {
*/
async assetRenamed (asset) {
WIKI.logger.info(`(STORAGE/${this.storageName}) Renaming file from ${asset.path} to ${asset.destinationPath}...`)
await this.s3.copyObject({ CopySource: asset.path, Key: asset.destinationPath }).promise()
await this.s3.copyObject({ CopySource: `${this.bucketName}/${asset.path}`, Key: asset.destinationPath }).promise()
await this.s3.deleteObject({ Key: asset.path }).promise()
}
async getLocalLocation () {
Expand Down