Skip to content

Commit 127d165

Browse files
committed
keep default getUrl expiry, add docs
1 parent 4aa7535 commit 127d165

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,14 @@ export const list = query({
263263
return Promise.all(
264264
messages.map(async (message) => ({
265265
...message,
266-
imageUrl: await r2.getUrl(message.imageKey),
266+
imageUrl: await r2.getUrl(
267+
message.imageKey,
268+
// Options object is optional, can be omitted
269+
{
270+
// Custom expiration time in seconds, default is 900 (15 minutes)
271+
expiresIn: 60 * 60 * 24, // 1 day
272+
}
273+
),
267274
}))
268275
);
269276
},

src/client/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ export class R2 {
145145
*
146146
* @param key - The R2 object key.
147147
* @param options - Optional config object.
148-
* - `expiresIn` - The number of seconds until the URL expires (default: 3600, max: 604800 for 7 days).
148+
* - `expiresIn` - The number of seconds until the URL expires (default: 900, max: 604800 for 7 days).
149149
* @returns A promise that resolves to a signed URL for the object.
150150
*/
151151
async getUrl(key: string, options: { expiresIn?: number } = {}) {
152-
const { expiresIn = 3600 } = options;
152+
const { expiresIn = 900 } = options;
153153
return await getSignedUrl(
154154
this.r2,
155155
new GetObjectCommand({ Bucket: this.config.bucket, Key: key }),

0 commit comments

Comments
 (0)