Skip to content

Commit 901c904

Browse files
committed
remove s3
1 parent dfa639a commit 901c904

File tree

7 files changed

+15
-67
lines changed

7 files changed

+15
-67
lines changed

Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/fn/storage.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
11
import { createServerFn } from "@tanstack/start";
2-
import { adminMiddleware, authenticatedMiddleware } from "~/lib/auth";
3-
import { createPresignedPost } from "@aws-sdk/s3-presigned-post";
4-
import { env } from "~/utils/env";
2+
import { adminMiddleware } from "~/lib/auth";
53
import { z } from "zod";
6-
import { s3Client } from "~/lib/s3";
74
import { generateRandomUUID } from "~/utils/uuid";
85
import { saveFile } from "~/utils/disk-storage";
96

10-
export const getPresignedPostUrlFn = createServerFn()
11-
.middleware([authenticatedMiddleware])
12-
.validator(z.object({ key: z.string(), contentType: z.string() }))
13-
.handler(async ({ data }) => {
14-
const { url, fields } = await createPresignedPost(s3Client, {
15-
Bucket: env.STORAGE_BUCKET_NAME,
16-
Key: data.key,
17-
Conditions: [
18-
["content-length-range", 0, 100 * 1024 * 1024], // up to 100MB
19-
["eq", "$Content-Type", data.contentType],
20-
],
21-
Fields: { "Content-Type": data.contentType },
22-
Expires: 600, // 10 minutes
23-
});
24-
25-
return { url, fields };
26-
});
27-
287
export const uploadVideoFn = createServerFn({ method: "POST" })
298
.middleware([adminMiddleware])
309
.validator(z.instanceof(FormData))

app/utils/storage.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
import { Segment } from "~/db/schema";
2-
import { getPresignedPostUrlFn } from "~/fn/storage";
32

43
export function getStorageUrl(segmentId: Segment["id"]) {
54
return `/api/segments/${segmentId}/video`;
65
}
7-
8-
export async function uploadFile(key: string, file: File) {
9-
const presignedPost = await getPresignedPostUrlFn({
10-
data: { key, contentType: file.type },
11-
});
12-
13-
const formData = new FormData();
14-
Object.entries(presignedPost.fields).forEach(([key, value]) => {
15-
formData.append(key, value);
16-
});
17-
formData.append("file", file);
18-
19-
const uploadResponse = await fetch(presignedPost.url, {
20-
method: "POST",
21-
body: formData,
22-
});
23-
24-
if (!uploadResponse.ok) {
25-
throw new Error("Failed to upload video");
26-
}
27-
}

cors.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
},
1919
"dependencies": {
2020
"@aws-sdk/client-s3": "^3.744.0",
21-
"@aws-sdk/s3-presigned-post": "^3.744.0",
2221
"@hello-pangea/dnd": "^18.0.1",
2322
"@hookform/resolvers": "^3.10.0",
2423
"@radix-ui/react-alert-dialog": "^1.1.6",

run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Source environment variables
4+
source .env
5+
6+
npm run build
7+
8+
# Start PM2 with environment variables
9+
pm2 start npm --name "wdc-tanstack-starter-kit" -- start

setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
sudo apt-get install -y curl
4+
curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh
5+
sudo -E bash nodesource_setup.sh

0 commit comments

Comments
 (0)