Skip to content

Commit a778e11

Browse files
authored
feat: support providing endpoint for output S3 (#235)
1 parent c568251 commit a778e11

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/TranscribeService/TranscribeService.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ export class TranscribeService {
133133
format,
134134
bucket,
135135
key,
136-
region
136+
region,
137+
endpoint
137138
}: TTranscribeRemoteFile & {
138139
bucket: string;
139140
key: string;
140141
region?: string;
142+
endpoint?: string;
141143
}): Promise<void> {
142144
try {
143145
this.workerState = State.ACTIVE;
@@ -155,6 +157,7 @@ export class TranscribeService {
155157
key,
156158
format,
157159
region,
160+
endpoint,
158161
content: JSON.stringify(resp)
159162
});
160163
// TODO: Find a way to not be dependent on the need to download the file locally

src/api.ts

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ const transcribeS3: FastifyPluginCallback<Options> = (fastify, _opts, next) => {
157157
},
158158
region: {
159159
type: 'string'
160+
},
161+
endpoint: {
162+
type: 'string'
160163
}
161164
},
162165
required: ['url', 'bucket', 'key']

src/aws/upload.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export async function uploadToS3({
3838
bucket,
3939
key,
4040
format,
41-
region
41+
region,
42+
endpoint
4243
}: TUploadToS3): Promise<void> {
4344
let fileFormat = 'txt';
4445
if (['json', 'verbose_json'].includes(format)) {
@@ -48,7 +49,12 @@ export async function uploadToS3({
4849
} else if (format === 'vtt') {
4950
fileFormat = 'vtt';
5051
}
51-
const client = new S3Client({ region: region ?? process.env.AWS_REGION });
52+
const customEndpoint = endpoint ?? process.env.AWS_S3_ENDPOINT;
53+
const client = new S3Client({
54+
region: region ?? process.env.AWS_REGION,
55+
forcePathStyle: customEndpoint ? true : false,
56+
endpoint: customEndpoint
57+
});
5258
const upload = new Upload({
5359
client,
5460
params: { Bucket: bucket, Key: `${key}.${fileFormat}`, Body: content }

0 commit comments

Comments
 (0)