@@ -279,6 +279,25 @@ export async function uploadToHetzner(
|
||||
return { key };
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a presigned PUT URL for direct browser-to-Hetzner uploads.
|
||||
* The caller must use the returned `key` to commit the upload via the API.
|
||||
* Expires in 1 hour by default.
|
||||
*/
|
||||
export async function generateHetznerPresignedUploadUrl(
|
||||
key: string,
|
||||
contentType: string,
|
||||
expiresIn: number = 3600
|
||||
): Promise<string> {
|
||||
const { client, bucket } = await buildHetznerClient();
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
ContentType: contentType,
|
||||
});
|
||||
return getSignedUrl(client, command, { expiresIn });
|
||||
}
|
||||
|
||||
/**
|
||||
* In-process cache for Hetzner key existence checks.
|
||||
* Positive hits (key exists) are cached indefinitely for the process lifetime
|
||||
|
||||
Reference in New Issue
Block a user