Skip to content

Commit 141e053

Browse files
committed
feat: adds note about the max file size
1 parent c3c6319 commit 141e053

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

app/routes/healthz.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @akoenig/remix-observable-file-upload-demo
3+
*
4+
* Copyright, 2023 - André König, Hamburg, Germany
5+
*
6+
* All rights reserved
7+
*/
8+
9+
/**
10+
* @author André König <[email protected]>
11+
*
12+
*/
13+
14+
export function loader() {
15+
return new Response();
16+
}

app/routes/upload.advanced.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export function loader() {
5656
export async function action({ request }: ActionFunctionArgs) {
5757
const start = Date.now();
5858

59+
const maxPartSize = 100_000_000;
60+
5961
const url = new URL(request.url);
6062
const uploadId = url.searchParams.get("uploadId");
6163

@@ -68,11 +70,19 @@ export async function action({ request }: ActionFunctionArgs) {
6870

6971
// Get the overall filesize of the uploadable file.
7072
const filesize = Number(request.headers.get("Content-Length"));
73+
74+
if (filesize > maxPartSize) {
75+
throw new Response(null, {
76+
status: 400,
77+
statusText: "File size exceeded",
78+
});
79+
}
80+
7181
const filesizeInKilobytes = Math.floor(filesize / 1024);
7282

7383
const observableFileUploadHandler = createObservableFileUploadHandler({
7484
avoidFileConflicts: true,
75-
maxPartSize: 100_000_000,
85+
maxPartSize,
7686
onProgress({ name, filename, uploadedBytes }) {
7787
const elapsedMilliseconds = Date.now() - start;
7888

@@ -158,6 +168,19 @@ export default function AdvancedExample() {
158168
/>
159169
</label>
160170

171+
<p className="text-center text-muted-foreground">
172+
<small>
173+
max. 100 MB (configurable via{" "}
174+
<Link
175+
to="https://github.com/akoenig/remix-observable-file-upload-demo/blob/33aa02bfa7703e02b2ea0033f6f83135ffb361ca/app/routes/upload.advanced.tsx#L75"
176+
className="text-pink-500 underline"
177+
>
178+
maxPartSize
179+
</Link>
180+
)
181+
</small>
182+
</p>
183+
161184
{progress?.success && progress.event ? (
162185
<div className="flex flex-col bg-slate-50 rounded-lg p-4 gap-4 border-slate-100 border-[1px]">
163186
<div className="flex gap-3">

app/routes/upload.basic.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export async function action({ request }: ActionFunctionArgs) {
5050
const url = new URL(request.url);
5151
const uploadId = url.searchParams.get("uploadId");
5252

53+
const maxPartSize = 100_000_000;
54+
5355
if (!uploadId) {
5456
throw new Response(null, {
5557
status: 400,
@@ -60,9 +62,16 @@ export async function action({ request }: ActionFunctionArgs) {
6062
// Get the overall filesize of the uploadable file.
6163
const filesize = Number(request.headers.get("Content-Length"));
6264

65+
if (filesize > maxPartSize) {
66+
throw new Response(null, {
67+
status: 400,
68+
statusText: "File size exceeded",
69+
});
70+
}
71+
6372
const observableFileUploadHandler = createObservableFileUploadHandler({
6473
avoidFileConflicts: true,
65-
maxPartSize: 100_000_000,
74+
maxPartSize,
6675
onProgress({ name, filename, uploadedBytes }) {
6776
uploadEventBus.emit<UploadProgressEvent>({
6877
uploadId,
@@ -126,6 +135,19 @@ export default function BasicExample() {
126135

127136
<Button type="submit">Upload</Button>
128137

138+
<p className="text-center text-muted-foreground">
139+
<small>
140+
max. 100 MB (configurable via{" "}
141+
<Link
142+
to="https://github.com/akoenig/remix-observable-file-upload-demo/blob/33aa02bfa7703e02b2ea0033f6f83135ffb361ca/app/routes/upload.basic.tsx#L65"
143+
className="text-pink-500 underline"
144+
>
145+
maxPartSize
146+
</Link>
147+
)
148+
</small>
149+
</p>
150+
129151
{progress?.success && progress.event ? (
130152
<div className="flex flex-col gap-4">
131153
<Progress value={progress.event.percentageStatus} />

fly.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ primary_region = "ams"
2424
timeout = "2s"
2525
grace_period = "5s"
2626
method = "GET"
27-
path = "/"
27+
path = "/healthz"
2828
protocol = "http"
2929
tls_skip_verify = false

0 commit comments

Comments
 (0)