Refactor content metadata handling in index.ts
This commit is contained in:
parent
a534702d24
commit
4788813c39
26
src/index.ts
26
src/index.ts
@ -151,28 +151,28 @@ async function handle_get(request: Request, bucket: R2Bucket): Promise<Response>
|
||||
|
||||
...(object.httpMetadata?.contentDisposition
|
||||
? {
|
||||
'Content-Disposition': object.httpMetadata.contentDisposition,
|
||||
}
|
||||
'Content-Disposition': object.httpMetadata.contentDisposition,
|
||||
}
|
||||
: {}),
|
||||
...(object.httpMetadata?.contentEncoding
|
||||
? {
|
||||
'Content-Encoding': object.httpMetadata.contentEncoding,
|
||||
}
|
||||
'Content-Encoding': object.httpMetadata.contentEncoding,
|
||||
}
|
||||
: {}),
|
||||
...(object.httpMetadata?.contentLanguage
|
||||
? {
|
||||
'Content-Language': object.httpMetadata.contentLanguage,
|
||||
}
|
||||
'Content-Language': object.httpMetadata.contentLanguage,
|
||||
}
|
||||
: {}),
|
||||
...(object.httpMetadata?.cacheControl
|
||||
? {
|
||||
'Cache-Control': object.httpMetadata.cacheControl,
|
||||
}
|
||||
'Cache-Control': object.httpMetadata.cacheControl,
|
||||
}
|
||||
: {}),
|
||||
...(object.httpMetadata?.cacheExpiry
|
||||
? {
|
||||
'Cache-Expiry': object.httpMetadata.cacheExpiry.toISOString(),
|
||||
}
|
||||
'Cache-Expiry': object.httpMetadata.cacheExpiry.toISOString(),
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
@ -305,9 +305,9 @@ function generate_propfind_response(object: R2Object | null): string {
|
||||
<propstat>
|
||||
<prop>
|
||||
${Object.entries(fromR2Object(object))
|
||||
.filter(([_, value]) => value !== undefined)
|
||||
.map(([key, value]) => `<${key}>${value}</${key}>`)
|
||||
.join('\n ')}
|
||||
.filter(([_, value]) => value !== undefined)
|
||||
.map(([key, value]) => `<${key}>${value}</${key}>`)
|
||||
.join('\n ')}
|
||||
</prop>
|
||||
<status>HTTP/1.1 200 OK</status>
|
||||
</propstat>
|
||||
|
Loading…
Reference in New Issue
Block a user