Skip to content

Commit 4f302df

Browse files
committed
fix: try resolve aws-sdk heroku error
1 parent 0efc313 commit 4f302df

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@types/mongoose": "^5.7.23",
2626
"@typescript-eslint/eslint-plugin": "^3.2.0",
2727
"@typescript-eslint/parser": "^3.2.0",
28-
"aws-sdk": "^2.729.0",
28+
"aws-sdk": "^2.6.1",
2929
"bluebird": "^3.7.2",
3030
"cors": "^2.8.5",
3131
"feathers-hooks-common": "^5.0.3",
@@ -47,7 +47,8 @@
4747
"homepage": "https://github.com/eug-vs/which-api#readme",
4848
"description": "",
4949
"devDependencies": {
50-
"@types/aws-sdk": "^2.7.0",
50+
"@types/aws-sdk": "^2.6.1",
51+
"@types/node": "^14.0.27",
5152
"@types/uuid": "^8.0.1",
5253
"eslint": "^7.2.0",
5354
"eslint-config-airbnb-typescript": "^8.0.2",

services/files/files.class.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import { Application } from '@feathersjs/express';
22
import { Params } from '@feathersjs/feathers';
3-
import { S3 } from 'aws-sdk';
4-
import { v4 as uuidv4 } from 'uuid';
3+
const { v4 } = require('uuid');
4+
const S3 = require('aws-sdk/clients/s3');
55

6+
console.log('AWS-SDK loaded!');
67

78
export default class Files {
89
app!: Application;
9-
s3!: S3;
10+
s3!: any;
1011
bucket!: string;
1112

1213
async find(params: Params): Promise<string> {
1314
// Return signed upload URL
1415
return this.s3.getSignedUrl('putObject', {
1516
Bucket: this.bucket,
16-
Key: `${params.user?.username}/${uuidv4()}.png`,
17+
Key: `${params.user?.username}/${v4()}.png`,
1718
ContentType: 'image/*',
1819
Expires: 300,
1920
});

0 commit comments

Comments
 (0)