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
|
...(object.httpMetadata?.contentDisposition
|
||||||
? {
|
? {
|
||||||
'Content-Disposition': object.httpMetadata.contentDisposition,
|
'Content-Disposition': object.httpMetadata.contentDisposition,
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
...(object.httpMetadata?.contentEncoding
|
...(object.httpMetadata?.contentEncoding
|
||||||
? {
|
? {
|
||||||
'Content-Encoding': object.httpMetadata.contentEncoding,
|
'Content-Encoding': object.httpMetadata.contentEncoding,
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
...(object.httpMetadata?.contentLanguage
|
...(object.httpMetadata?.contentLanguage
|
||||||
? {
|
? {
|
||||||
'Content-Language': object.httpMetadata.contentLanguage,
|
'Content-Language': object.httpMetadata.contentLanguage,
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
...(object.httpMetadata?.cacheControl
|
...(object.httpMetadata?.cacheControl
|
||||||
? {
|
? {
|
||||||
'Cache-Control': object.httpMetadata.cacheControl,
|
'Cache-Control': object.httpMetadata.cacheControl,
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
...(object.httpMetadata?.cacheExpiry
|
...(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>
|
<propstat>
|
||||||
<prop>
|
<prop>
|
||||||
${Object.entries(fromR2Object(object))
|
${Object.entries(fromR2Object(object))
|
||||||
.filter(([_, value]) => value !== undefined)
|
.filter(([_, value]) => value !== undefined)
|
||||||
.map(([key, value]) => `<${key}>${value}</${key}>`)
|
.map(([key, value]) => `<${key}>${value}</${key}>`)
|
||||||
.join('\n ')}
|
.join('\n ')}
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 200 OK</status>
|
<status>HTTP/1.1 200 OK</status>
|
||||||
</propstat>
|
</propstat>
|
||||||
|
Loading…
Reference in New Issue
Block a user