Skip to content

Commit 99c7a1c

Browse files
committed
feat: add aws provider implementation
1 parent 99a1a80 commit 99c7a1c

File tree

7 files changed

+389
-337
lines changed

7 files changed

+389
-337
lines changed

src/providers/aws.js

Lines changed: 114 additions & 109 deletions
Large diffs are not rendered by default.

src/providers/factory.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,14 @@ class ProviderFactory {
6161
// eslint-disable-next-line class-methods-use-this
6262
getProviderAWS(transport) {
6363
const ProviderAWS = require('./aws');
64-
const provider = new ProviderAWS(transport);
64+
const bucket = transport.options.bucket.name;
65+
66+
// delegate logging facility
67+
transport.options.logger = this.logger.child({ bucket });
68+
69+
// init provider
70+
debug('passing options %j', transport.options);
71+
const provider = new ProviderAWS(transport.options);
6572

6673
return provider;
6774
}

src/providers/gce.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class GCETransport extends AbstractFileTransfer {
1919
constructor(opts = {}) {
2020
super();
2121
this._config = merge({}, GCETransport.defaultOpts, opts);
22+
2223
this._logger = this._config.logger;
2324
this.setupGCE();
2425
}

test/configs/generic/core.js

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,46 @@ exports.amqp = {
1919
},
2020
};
2121

22-
exports.transport = [{
23-
name: 'gce',
24-
options: {
25-
gce: {
26-
projectId: env.GCLOUD_PROJECT_ID,
27-
credentials: {
28-
client_email: env.GCLOUD_PROJECT_EMAIL,
29-
private_key: env.GCLOUD_PROJECT_PK,
22+
exports.transport = [
23+
// {
24+
// name: 'gce',
25+
// options: {
26+
// gce: {
27+
// projectId: env.GCLOUD_PROJECT_ID,
28+
// credentials: {
29+
// client_email: env.GCLOUD_PROJECT_EMAIL,
30+
// private_key: env.GCLOUD_PROJECT_PK,
31+
// },
32+
// },
33+
// bucket: {
34+
// name: env.TEST_BUCKET,
35+
// metadata: {
36+
// location: env.GCLOUD_BUCKET_LOCATION || 'EUROPE-WEST1',
37+
// dra: true,
38+
// },
39+
// },
40+
// // test for direct public URLs
41+
// },
42+
// // its not a public name!
43+
// cname: 'gce',
44+
// },
45+
{
46+
name: 'aws',
47+
options: {
48+
aws: {
49+
credentials: {
50+
accessKeyId: env.AWS_ACCESS_KEY_ID,
51+
secretAccessKey: env.AWS_SECRET_ACCESS_KEY,
52+
},
3053
},
31-
},
32-
bucket: {
33-
name: env.TEST_BUCKET,
34-
metadata: {
35-
location: env.GCLOUD_BUCKET_LOCATION || 'EUROPE-WEST1',
36-
dra: true,
37-
},
38-
},
39-
// test for direct public URLs
40-
},
41-
// its not a public name!
42-
cname: 'gce',
43-
},
44-
{
45-
name: 'aws',
46-
options: {
47-
aws: {
48-
credentials: {
49-
accessKeyId: env.AWS_ACCESS_KEY_ID,
50-
secretAccessKey: env.AWS_SECRET_ACCESS_KEY,
54+
bucket: {
55+
name: env.TEST_BUCKET,
5156
},
57+
// test for direct public URLs
5258
},
53-
bucket: {
54-
name: env.TEST_BUCKET,
55-
},
56-
// test for direct public URLs
57-
},
58-
// its not a public name!
59-
cname: 'aws',
60-
}];
59+
// its not a public name!
60+
cname: 'aws',
61+
}];
6162

6263
exports.hooks = {
6364
// return input, assume there are models

test/helpers/utils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function upload(location, file) {
188188
});
189189
}
190190

191-
function uploadSimple(meta, file, isPublic) {
191+
async function uploadSimple(meta, file, isPublic) {
192192
const { query: { Expires } } = url.parse(meta.location);
193193

194194
const headers = {
@@ -204,9 +204,10 @@ function uploadSimple(meta, file, isPublic) {
204204
return request.put({
205205
url: meta.location,
206206
body: file,
207-
headers,
208-
simple: false,
207+
// headers,
208+
// simple: false,
209209
resolveWithFullResponse: true,
210+
ACL: 'public-read',
210211
});
211212
}
212213

@@ -222,6 +223,7 @@ function uploadFiles(msg, rsp) {
222223
const file = files[idx];
223224
const { location } = part;
224225
const isSimple = location.indexOf('Signature') !== -1;
226+
console.log('isSimple upload', isSimple);
225227
return isSimple ? uploadSimple(part, file, rsp.public) : upload(location, file);
226228
});
227229
}

0 commit comments

Comments
 (0)