Customisable token duration
This commit is contained in:
@@ -16,6 +16,8 @@ export async function GET({ url }) {
|
||||
}
|
||||
});
|
||||
|
||||
const tokenDuration = parseInt(env.B2_TOKEN_DURATION, 10) || 600;
|
||||
|
||||
// Fetch a batch of files from the thumbs/ folder
|
||||
const listCommand = new ListObjectsV2Command({
|
||||
Bucket: env.B2_BUCKET_NAME,
|
||||
@@ -44,8 +46,8 @@ export async function GET({ url }) {
|
||||
|
||||
// 10 minutes = 600 seconds
|
||||
const [thumbUrl, fullUrl] = await Promise.all([
|
||||
getSignedUrl(s3, thumbCommand, { expiresIn: 600 }),
|
||||
getSignedUrl(s3, fullCommand, { expiresIn: 600 })
|
||||
getSignedUrl(s3, thumbCommand, { expiresIn: tokenDuration }),
|
||||
getSignedUrl(s3, fullCommand, { expiresIn: tokenDuration })
|
||||
]);
|
||||
|
||||
return { id, thumbUrl, fullUrl };
|
||||
|
||||
Reference in New Issue
Block a user