(input: S3ConfigInput)
| 425 | } |
| 426 | |
| 427 | export async function testOrganizationS3Config(input: S3ConfigInput) { |
| 428 | await requireOrganizationStorageManagerPro(input.organizationId); |
| 429 | const credentials = await getS3InputCredentials(input); |
| 430 | const controller = new AbortController(); |
| 431 | const timeoutId = setTimeout(() => controller.abort(), 5000); |
| 432 | const s3Client = new S3Client({ |
| 433 | endpoint: input.endpoint || undefined, |
| 434 | region: input.region, |
| 435 | credentials: { |
| 436 | accessKeyId: credentials.accessKeyId, |
| 437 | secretAccessKey: credentials.secretAccessKey, |
| 438 | }, |
| 439 | }); |
| 440 | |
| 441 | try { |
| 442 | await s3Client.send(new HeadBucketCommand({ Bucket: input.bucketName }), { |
| 443 | abortSignal: controller.signal, |
| 444 | }); |
| 445 | return { success: true }; |
| 446 | } catch (error) { |
| 447 | throw new Error(getS3ConnectionErrorMessage(error, input.bucketName)); |
| 448 | } finally { |
| 449 | clearTimeout(timeoutId); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | export async function setOrganizationStorageProvider({ |
| 454 | organizationId, |
no test coverage detected