Skip to content

Commit d57e668

Browse files
committed
feat: add option to keep original file name in aws s3
1 parent 0c792d4 commit d57e668

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"pino-pretty": "^10.2.3",
124124
"poolifier": "^3.0.0",
125125
"preview-email": "^3.0.19",
126-
"prom-client": "^14.2.0",
126+
"prom-client": "^15.0.0",
127127
"pug": "^3.0.2",
128128
"qrcode": "^1.5.3",
129129
"read-pkg": "^8.1.0",

pnpm-lock.yaml

+14-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/aws/aws.interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface AwsS3MultiPart extends AwsS3 {
1616
export interface AwsS3PutItemOptions {
1717
acl?: ObjectCannedACL
1818
path: string
19+
keepOriginalName?: boolean
1920
}
2021

2122
export interface AwsModuleOptions {

src/lib/aws/aws.s3.service.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import type {
2323
import { AwsModuleOptions } from "./aws.interface";
2424
import { MODULE_OPTIONS_TOKEN } from "./aws.module";
2525

26+
// TODO: convert to observables
27+
2628
@Injectable()
2729
export class AwsS3Service {
2830
private readonly s3Client: S3Client;
@@ -166,7 +168,7 @@ export class AwsS3Service {
166168
content: Uint8Array | Buffer,
167169
options?: AwsS3PutItemOptions,
168170
): Promise<AwsS3> {
169-
const filename = this.generateFileName(originalFilename);
171+
const filename = options.keepOriginalName ? originalFilename : this.generateFileName(originalFilename);
170172
const { key, mime, path } = this.getOptions(options, filename);
171173
await this.s3Client.send(
172174
new PutObjectCommand({

0 commit comments

Comments
 (0)