-
Notifications
You must be signed in to change notification settings - Fork 620
/
Copy pathreadObject.ts
54 lines (49 loc) · 1.59 KB
/
readObject.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { AmazonS3Client } from '@rushstack/rush-amazon-s3-build-cache-plugin';
import { WebClient } from '@microsoft/rush-lib/lib/utilities/WebClient';
import { ConsoleTerminalProvider, type ITerminal, Terminal } from '@rushstack/terminal';
const webClient: WebClient = new WebClient();
const terminal: ITerminal = new Terminal(
new ConsoleTerminalProvider({
verboseEnabled: true,
debugEnabled: true
})
);
const client: AmazonS3Client = new AmazonS3Client(
{
accessKeyId: 'minio',
secretAccessKey: 'minio123',
sessionToken: undefined
},
{
s3Endpoint: 'http://localhost:9000',
s3Region: 'eu-west-1',
isCacheWriteAllowed: true,
s3Prefix: undefined
},
webClient,
terminal
);
async function main(): Promise<void> {
const response: Buffer | undefined = await client.getObjectAsync('rush-build-cache/testfile.txt');
if (response) {
if (response.toString().match('remote file from the rush build cache')) {
// eslint-disable-next-line no-console
console.log('✅ Success!');
} else {
// eslint-disable-next-line no-console
console.log('❌ Error: response does not match the file in s3data/rush-build-cache/testfile.txt');
process.exit(1);
}
} else {
// eslint-disable-next-line no-console
console.error('❌ Error: no response');
process.exit(1);
}
}
main().catch((err) => {
// eslint-disable-next-line no-console
console.error(err);
process.exit(1);
});