Skip to content

Commit 1fb39b9

Browse files
authored
Merge pull request #184 from chrisgo/master
Closes #140, add ability to set region for S3 uploads
2 parents c4ac447 + 9354122 commit 1fb39b9

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The user must be a member of the project you want to copy. This user must be the
4242

4343
### Docker
4444

45-
If you don't have Node.js installed in your local environment and don't want to install it you can use the Dockerized approach.
45+
If you don't have Node.js installed in your local environment and don't want to install it you can use the Dockerized approach.
4646

4747
1. Make sure that you have [Docker](https://docs.docker.com/engine/install/) installed in your computer. You can test running `docker version` in the terminal.
4848
1. `cp sample_settings.ts settings.ts`
@@ -144,6 +144,10 @@ IAM User who owns these credential must have [write permissions](https://docs.aw
144144

145145
Existing bucket, with an appropriate security policy. One possible policy is to allow [public access](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteAccessPermissionsReqd.html).
146146

147+
#### s3.region
148+
149+
Specify Region (example: us-west-1) of bucket [list of regions](https://docs.aws.amazon.com/general/latest/gr/s3.html)
150+
147151
### usermap
148152

149153
Maps the usernames from gitlab to github. If the assinee of the gitlab issue is equal to the one currently logged in github it will also get assigned without a usermap. The Mentions in issues will also be translated to the new github name.

sample_settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default {
2222
accessKeyId: '{{accessKeyId}}',
2323
secretAccessKey: '{{secretAccessKey}}',
2424
bucket: 'my-gitlab-bucket',
25+
region: null,
2526
},
2627
usermap: {
2728
'username.gitlab.1': 'username.github.1',

src/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ export interface S3Settings {
6060
accessKeyId: string;
6161
secretAccessKey: string;
6262
bucket: string;
63+
region: string;
6364
}

src/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ export const migrateAttachments = async (
4949
// Doesn't seem like it is easy to upload an issue to github, so upload to S3
5050
//https://stackoverflow.com/questions/41581151/how-to-upload-an-image-to-use-in-issue-comments-via-github-api
5151

52-
const s3url = `https://${s3.bucket}.s3.amazonaws.com/${relativePath}`;
52+
// Attempt to fix issue #140
53+
//const s3url = `https://${s3.bucket}.s3.amazonaws.com/${relativePath}`;
54+
let hostname = `${s3.bucket}.s3.amazonaws.com`;
55+
if (s3.region) {
56+
hostname = `s3.${s3.region}.amazonaws.com/${s3.bucket}`;
57+
}
58+
const s3url = `https://${hostname}/${relativePath}`;
5359

5460
const s3bucket = new S3();
5561
s3bucket.createBucket(() => {

0 commit comments

Comments
 (0)