-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathpage.tsx
84 lines (68 loc) · 2.15 KB
/
page.tsx
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use client';
import React, { useEffect } from 'react';
import { Amplify } from 'aws-amplify';
import { signOut, fetchUserAttributes } from 'aws-amplify/auth';
import { Button, withAuthenticator } from '@aws-amplify/ui-react';
import {
createStorageBrowser,
createAmplifyAuthAdapter,
elementsDefault,
} from '@aws-amplify/ui-react-storage/browser';
import '@aws-amplify/ui-react-storage/styles.css';
import '@aws-amplify/ui-react-storage/storage-browser-styles.css';
//import { S3 } from "aws-sdk";
//import WrappedStorageBrowser from './WrappedStorageBrowser'; // Adjust the path if needed
import config from '../amplify_outputs.json';
Amplify.configure(config);
// Create an S3 client (make sure to set the region and any required credentials)
//const s3 = new S3({ region: config.auth.aws_region });
function Example() {
useEffect(() => {
//To console log user attributes using fetchUserAttributes()
async function getAttributes() {
try {
const attributes = await fetchUserAttributes();
console.log("User Attributes:", attributes);
} catch (error) {
console.error("Error fetching user attributes", error);
}
}
getAttributes();
}, []);
const { StorageBrowser } = createStorageBrowser({
elements: elementsDefault,
config: createAmplifyAuthAdapter({
options: {
defaultPrefixes: [
'ConversionFiles/',
'ConversionFileErrors/',
'InitialUpload/',
'InitialUploadErrors/',
'TSQLFiles/',
'DataValidation/',
// (identityId: string) => `private/${identityId}/`,
/*"media-readwritedelete/",
"media-readonly/",
"shared-folder-readwrite/",
(identityId: string) => `protected-useronlyreadwritedelete/${identityId}/`,
(identityId: string) => `private-useronlyreadwritedelete/${identityId}/`,*/
],
},
}),
});
return (
<>
<Button
marginBlockEnd="xl"
size="small"
onClick={() => {
signOut();
}}
>
Sign Out
</Button>
<StorageBrowser />
</>
);
}
export default withAuthenticator(Example);