feat: add content length to file upload endpoint, cors for local dev

This commit is contained in:
BennyKok 2024-01-16 00:46:07 +08:00
parent aa0e3e987c
commit 478859d9b5
4 changed files with 21 additions and 2 deletions

View File

@ -1,2 +1,3 @@
#!/usr/bin/env bash
awslocal s3 mb s3://comfyui-deploy
awslocal s3 mb s3://comfyui-deploy
awslocal s3api put-bucket-cors --bucket comfyui-deploy --cors-configuration file:///app/web/aws/cors-config.json

15
web/aws/cors-config.json Normal file
View File

@ -0,0 +1,15 @@
{
"CORSRules": [
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"PUT"
],
"AllowedOrigins": [
"*"
]
}
]
}

View File

@ -27,4 +27,5 @@ services:
ports:
- 4566:4566
volumes:
- ./aws:/etc/localstack/init/ready.d
- ./aws:/etc/localstack/init/ready.d
- ./aws:/app/web/aws

View File

@ -23,6 +23,7 @@ export type ResourceObject = {
resourceId: string;
resourceType: "image/png" | "application/zip" | string;
isPublic?: boolean;
size?: number;
};
export async function handleResourceUpload(
@ -32,6 +33,7 @@ export async function handleResourceUpload(
Key: resource.resourceId,
Bucket: resource.resourceBucket,
ContentType: resource.resourceType,
ContentLength: resource.size,
};
// Only set ACL if resource is public