mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-23 01:29:40 +02:00
create a new s3 client for each request
This commit is contained in:
+4
-3
@@ -2,7 +2,6 @@ import { StorageBase, Tree, TreeFile } from "../types";
|
|||||||
import { S3 } from "aws-sdk";
|
import { S3 } from "aws-sdk";
|
||||||
import config from "../../config";
|
import config from "../../config";
|
||||||
import * as stream from "stream";
|
import * as stream from "stream";
|
||||||
import { promisify } from "util";
|
|
||||||
import { ArchiveStreamToS3 } from "archive-stream-to-s3";
|
import { ArchiveStreamToS3 } from "archive-stream-to-s3";
|
||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import * as mime from "mime-types";
|
import * as mime from "mime-types";
|
||||||
@@ -17,14 +16,16 @@ const originalArchiveStreamToS3Entry: Function = (ArchiveStreamToS3 as any)
|
|||||||
|
|
||||||
export default class S3Storage implements StorageBase {
|
export default class S3Storage implements StorageBase {
|
||||||
type = "AWS";
|
type = "AWS";
|
||||||
client: S3;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (!config.S3_BUCKET)
|
if (!config.S3_BUCKET)
|
||||||
throw new AnonymousError("s3_config_not_provided", {
|
throw new AnonymousError("s3_config_not_provided", {
|
||||||
httpStatus: 500,
|
httpStatus: 500,
|
||||||
});
|
});
|
||||||
this.client = new S3({
|
}
|
||||||
|
|
||||||
|
get client() {
|
||||||
|
return new S3({
|
||||||
region: config.S3_REGION,
|
region: config.S3_REGION,
|
||||||
endpoint: config.S3_ENDPOINT,
|
endpoint: config.S3_ENDPOINT,
|
||||||
accessKeyId: config.S3_CLIENT_ID,
|
accessKeyId: config.S3_CLIENT_ID,
|
||||||
|
|||||||
Reference in New Issue
Block a user