MCPcopy Index your code
hub / github.com/simstudioai/sim / headS3Object

Function headS3Object

apps/sim/lib/uploads/providers/s3/client.ts:243–266  ·  view source on GitHub ↗
(
  key: string,
  customConfig?: S3Config
)

Source from the content-addressed store, hash-verified

241 * Returns null when the object is missing.
242 */
243export async function headS3Object(
244 key: string,
245 customConfig?: S3Config
246): Promise<{ size: number; contentType?: string } | null> {
247 const config = customConfig || { bucket: S3_CONFIG.bucket, region: S3_CONFIG.region }
248
249 try {
250 const response = await getS3Client().send(
251 new HeadObjectCommand({ Bucket: config.bucket, Key: key })
252 )
253 return {
254 size: response.ContentLength ?? 0,
255 contentType: response.ContentType,
256 }
257 } catch (error) {
258 const code = (error as { name?: string; $metadata?: { httpStatusCode?: number } } | null)?.name
259 const status = (error as { $metadata?: { httpStatusCode?: number } } | null)?.$metadata
260 ?.httpStatusCode
261 if (code === 'NotFound' || code === 'NoSuchKey' || status === 404) {
262 return null
263 }
264 throw error
265 }
266}
267
268/**
269 * Delete a file from S3

Callers 1

headObjectFunction · 0.85

Calls 2

getS3ClientFunction · 0.85
sendMethod · 0.80

Tested by

no test coverage detected