diff options
author | eug-vs <eug-vs@keemail.me> | 2020-08-10 23:47:00 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-08-11 14:24:47 +0300 |
commit | c2e16321e679d52ad9d6e08b5cdb785b172ad830 (patch) | |
tree | 8af4fdd11808b2620eadbf8321d76da41dbc1ab3 /services | |
parent | 0efc3134eb348e68e7bf7519e770237e15811900 (diff) | |
download | which-api-c2e16321e679d52ad9d6e08b5cdb785b172ad830.tar.gz |
fix: try resolve aws-sdk heroku error
Diffstat (limited to 'services')
-rw-r--r-- | services/files/files.class.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/services/files/files.class.ts b/services/files/files.class.ts index 8a104b7..e2f9df3 100644 --- a/services/files/files.class.ts +++ b/services/files/files.class.ts @@ -1,19 +1,22 @@ import { Application } from '@feathersjs/express'; import { Params } from '@feathersjs/feathers'; -import { S3 } from 'aws-sdk'; -import { v4 as uuidv4 } from 'uuid'; +import { v4 } from 'uuid'; + +// Use require to avoid bug +// https://stackoverflow.com/questions/62611373/heroku-crashes-when-importing-aws-sdk +const S3 = require('aws-sdk/clients/s3'); export default class Files { app!: Application; - s3!: S3; + s3!: any; bucket!: string; async find(params: Params): Promise<string> { // Return signed upload URL return this.s3.getSignedUrl('putObject', { Bucket: this.bucket, - Key: `${params.user?.username}/${uuidv4()}.png`, + Key: `${params.user?.username}/${v4()}.png`, ContentType: 'image/*', Expires: 300, }); |