diff --git a/src/handlers/requestHandler.ts b/src/handlers/requestHandler.ts index dc6fb10..a3b1c9a 100644 --- a/src/handlers/requestHandler.ts +++ b/src/handlers/requestHandler.ts @@ -15,12 +15,11 @@ export async function handleRequest(request: Request, env: Env, ctx: ExecutionCo }); } - const response = await handleWebDAV(request, env); - + const response = await handleWebDAV(request, env.BUCKET, env.BUCKET_NAME, env); // 传递 env 参数 setCORSHeaders(response, request); return response; } catch (error) { logger.error("Error in request handling:", error); return new Response("Internal Server Error", { status: 500 }); } -} \ No newline at end of file +} diff --git a/src/handlers/webdavHandler.ts b/src/handlers/webdavHandler.ts index a13ba17..aca5b46 100644 --- a/src/handlers/webdavHandler.ts +++ b/src/handlers/webdavHandler.ts @@ -8,9 +8,7 @@ import { WebDAVProps, Env } from '../types'; const SUPPORT_METHODS = ["OPTIONS", "PROPFIND", "MKCOL", "GET", "HEAD", "PUT", "COPY", "MOVE", "DELETE"]; const DAV_CLASS = "1, 2"; -export async function handleWebDAV(request: Request, env: Env): Promise { - const bucket = env.BUCKET; - const bucketName = env.BUCKET_NAME; +export async function handleWebDAV(request: Request, bucket: R2Bucket, bucketName: string, env: Env): Promise { // 身份验证处理 if (!authenticate(request, env)) {