From c2e16321e679d52ad9d6e08b5cdb785b172ad830 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 10 Aug 2020 23:47:00 +0300 Subject: fix: try resolve aws-sdk heroku error --- services/files/files.class.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'services/files') 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 { // 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, }); -- cgit v1.2.3