Skip to content

Commit e96c81e

Browse files
committed
feat: rebased master
2 parents 11d8e9e + b9acc7c commit e96c81e

28 files changed

+1870
-31
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
do $$
2+
declare
3+
super_user text = coalesce(current_setting('storage.super_user', true), 'postgres');
4+
begin
5+
execute 'grant all on storage.buckets, storage.objects to ' || super_user || ' with grant option';
6+
end $$;
7+
8+
do $$
9+
declare
10+
anon_role text = coalesce(current_setting('storage.anon_role', true), 'anon');
11+
authenticated_role text = coalesce(current_setting('storage.authenticated_role', true), 'authenticated');
12+
service_role text = coalesce(current_setting('storage.service_role', true), 'service_role');
13+
begin
14+
execute 'grant all on storage.buckets, storage.objects to ' || service_role || ', ' || authenticated_role || ', ' || anon_role;
15+
end $$;

src/http/routes/object/createObject.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface createObjectRequestInterface extends RequestGenericInterface {
3232
'content-type': string
3333
'cache-control'?: string
3434
'x-upsert'?: string
35+
'x-robots-tag'?: string
3536
}
3637
}
3738

src/http/routes/object/getObject.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,21 @@ async function requestHandler(
7171

7272
if (bucket.public) {
7373
// request is authenticated but we still use the superUser as we don't need to check RLS
74-
obj = await request.storage.asSuperUser().from(bucketName).findObject(objectName, 'id, version')
74+
obj = await request.storage
75+
.asSuperUser()
76+
.from(bucketName)
77+
.findObject(objectName, 'id, version, metadata')
7578
} else {
7679
// request is authenticated use RLS
77-
obj = await request.storage.from(bucketName).findObject(objectName, 'id, version')
80+
obj = await request.storage.from(bucketName).findObject(objectName, 'id, version, metadata')
7881
}
7982

8083
return request.storage.renderer('asset').render(request, response, {
8184
bucket: storageS3Bucket,
8285
key: s3Key,
8386
version: obj.version,
8487
download,
88+
xRobotsTag: obj.metadata?.['xRobotsTag'] as string | undefined,
8589
signal: request.signals.disconnect.signal,
8690
})
8791
}
@@ -95,6 +99,7 @@ export default async function routes(fastify: FastifyInstance) {
9599
// @todo add success response schema here
96100
schema: {
97101
params: getObjectParamsSchema,
102+
querystring: getObjectQuerySchema,
98103
headers: { $ref: 'authSchema#' },
99104
summary,
100105
response: { '4xx': { $ref: 'errorSchema#', description: 'Error response' } },

src/http/routes/object/getPublicObject.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default async function routes(fastify: FastifyInstance) {
3838
exposeHeadRoute: false,
3939
schema: {
4040
params: getPublicObjectParamsSchema,
41+
querystring: getObjectQuerySchema,
4142
summary,
4243
response: { '4xx': { $ref: 'errorSchema#', description: 'Error response' } },
4344
tags: ['object'],
@@ -56,7 +57,7 @@ export default async function routes(fastify: FastifyInstance) {
5657
request.storage.asSuperUser().findBucket(bucketName, 'id,public', {
5758
isPublic: true,
5859
}),
59-
bucketRef.findObject(objectName, 'id,version'),
60+
bucketRef.findObject(objectName, 'id,version,metadata'),
6061
])
6162

6263
// send the object from s3
@@ -71,6 +72,7 @@ export default async function routes(fastify: FastifyInstance) {
7172
key: s3Key,
7273
version: obj.version,
7374
download,
75+
xRobotsTag: obj.metadata?.['xRobotsTag'] as string | undefined,
7476
signal: request.signals.disconnect.signal,
7577
})
7678
}

src/http/routes/object/getSignedObject.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ export default async function routes(fastify: FastifyInstance) {
8383
const obj = await request.storage
8484
.asSuperUser()
8585
.from(bucketName)
86-
.findObject(objParts.join('/'), 'id,version')
86+
.findObject(objParts.join('/'), 'id,version,metadata')
8787

8888
return request.storage.renderer('asset').render(request, response, {
8989
bucket: storageS3Bucket,
9090
key: s3Key,
9191
version: obj.version,
9292
download,
9393
expires: new Date(exp * 1000).toUTCString(),
94+
xRobotsTag: obj.metadata?.['xRobotsTag'] as string | undefined,
9495
signal: request.signals.disconnect.signal,
9596
})
9697
}

src/http/routes/object/updateObject.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface updateObjectRequestInterface extends RequestGenericInterface {
2929
'content-type': string
3030
'cache-control'?: string
3131
'x-upsert'?: string
32+
'x-robots-tag'?: string
3233
}
3334
}
3435

src/http/routes/render/renderAuthenticatedImage.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export default async function routes(fastify: FastifyInstance) {
5151
const { bucketName } = request.params
5252
const objectName = request.params['*']
5353

54-
const obj = await request.storage.from(bucketName).findObject(objectName, 'id,version')
54+
const obj = await request.storage
55+
.from(bucketName)
56+
.findObject(objectName, 'id,version,metadata')
5557

5658
const s3Key = request.storage.location.getKeyLocation({
5759
tenantId: request.tenantId,
@@ -73,6 +75,7 @@ export default async function routes(fastify: FastifyInstance) {
7375
key: s3Key,
7476
version: obj.version,
7577
download,
78+
xRobotsTag: obj.metadata?.['xRobotsTag'] as string | undefined,
7679
signal: request.signals.disconnect.signal,
7780
})
7881
}

src/http/routes/render/renderPublicImage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default async function routes(fastify: FastifyInstance) {
5656
request.storage.asSuperUser().findBucket(bucketName, 'id,public', {
5757
isPublic: true,
5858
}),
59-
bucketRef.findObject(objectName, 'id,version'),
59+
bucketRef.findObject(objectName, 'id,version,metadata'),
6060
])
6161

6262
const s3Key = `${request.tenantId}/${bucketName}/${objectName}`
@@ -75,6 +75,7 @@ export default async function routes(fastify: FastifyInstance) {
7575
key: s3Key,
7676
version: obj.version,
7777
download,
78+
xRobotsTag: obj.metadata?.['xRobotsTag'] as string | undefined,
7879
signal: request.signals.disconnect.signal,
7980
})
8081
}

0 commit comments

Comments
 (0)