21 lines
		
	
	
		
			598 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			598 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
 | 
						|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
 | 
						|
 | 
						|
export const s3 = new S3Client({
 | 
						|
  region: "us-east-1",
 | 
						|
  endpoint: "http://10.0.20.11:9010",
 | 
						|
  forcePathStyle: true,
 | 
						|
  credentials: {
 | 
						|
    accessKeyId: "fellies",
 | 
						|
    secretAccessKey: "XCJ7spqxWZhVn8tkYnfVBFbz2cRKYxPAfeQeIdPRp1",
 | 
						|
  },
 | 
						|
});
 | 
						|
 | 
						|
export async function getSignedImageUrl(key: string, expiresInSec = 3600) {
 | 
						|
  const command = new GetObjectCommand({
 | 
						|
    Bucket: "gaertanapp",
 | 
						|
    Key: key,
 | 
						|
  });
 | 
						|
 | 
						|
  return getSignedUrl(s3, command, { expiresIn: expiresInSec });
 | 
						|
} |