mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 14:41:28 -07:00
updates to uuids to be consistent
This commit is contained in:
@@ -64,7 +64,7 @@ export const imageRoutes = new Hono<App>({ strict: false })
|
||||
// The `img` worker serves it back by that key (slashes and all), which is the
|
||||
// returned ImageName.
|
||||
const datePrefix = new Date().toISOString().slice(0, 10) + '/'
|
||||
const name = datePrefix + crypto.randomUUID().replace(/-/g, '') + extension
|
||||
const name = datePrefix + crypto.randomUUID() + extension
|
||||
await c.env.IMAGES.put(name, await file.arrayBuffer(), {
|
||||
httpMetadata: { contentType: file.type || 'image/jpeg' },
|
||||
})
|
||||
|
||||
@@ -325,7 +325,9 @@ describe('images', () => {
|
||||
})
|
||||
expect(res.status).toBe(200)
|
||||
const { ImageName } = (await res.json()) as { ImageName: string }
|
||||
expect(ImageName).toMatch(/^\d{4}-\d{2}-\d{2}\/[0-9a-f]+\.png$/)
|
||||
expect(ImageName).toMatch(
|
||||
/^\d{4}-\d{2}-\d{2}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.png$/
|
||||
)
|
||||
|
||||
// The object is in the shared bucket under that key.
|
||||
const stored = await env.IMAGES.get(ImageName)
|
||||
@@ -470,7 +472,9 @@ describe('images', () => {
|
||||
})
|
||||
expect(res.status).toBe(200)
|
||||
const { ImageName } = (await res.json()) as { ImageName: string }
|
||||
expect(ImageName).toMatch(/^\d{4}-\d{2}-\d{2}\/[0-9a-f]+\.jpg$/)
|
||||
expect(ImageName).toMatch(
|
||||
/^\d{4}-\d{2}-\d{2}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.jpg$/
|
||||
)
|
||||
|
||||
// The account row now points its profileImage at the uploaded key.
|
||||
const row = await env.DB.prepare('SELECT data FROM accounts WHERE account_id = 42').first<{
|
||||
|
||||
Reference in New Issue
Block a user