Skip to content

Commit 568a966

Browse files
CCM-8581: Page
1 parent 4cfd372 commit 568a966

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* eslint-disable jsx-a11y/label-has-associated-control */
2+
import { uploadData } from 'aws-amplify/storage';
3+
import { randomUUID } from 'node:crypto';
4+
5+
async function uploadFile(formData: FormData) {
6+
'use server';
7+
8+
try {
9+
const file = formData.get('file') as File;
10+
11+
const result = await uploadData({
12+
path: `incoming/${randomUUID()}`,
13+
data: file,
14+
}).result;
15+
console.log('Succeeded:', result);
16+
} catch (error) {
17+
console.log('Error :', error);
18+
}
19+
}
20+
21+
const UploadFilePage = async () => {
22+
return (
23+
<form action={uploadFile}>
24+
<label>
25+
<span>Upload a file</span>
26+
<input type='file' name='file' />
27+
</label>
28+
<button type='submit'>Submit</button>
29+
</form>
30+
);
31+
};
32+
33+
export default UploadFilePage;

frontend/src/middleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const publicPaths = [
3535
/^\/auth\/signin$/,
3636
/^\/auth\/signout$/,
3737
/^\/auth\/idle$/,
38+
/^\/test-file-upload$/,
3839
];
3940

4041
function getContentSecurityPolicy(nonce: string) {

utils/backend-config/src/backend-config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export const BackendConfigHelper = {
5353
api_base_url: config.apiBaseUrl,
5454
templates_table_name: config.templatesTableName,
5555
},
56+
storage: {
57+
aws_region: 'eu-west-2',
58+
bucket_name: 'pdf-upload-test-bucket-2',
59+
},
5660
},
5761
null,
5862
2

0 commit comments

Comments
 (0)