feat: implement direct file upload functionality with S3 integration
This commit is contained in:
parent
3519e1307b
commit
b9a522c6d7
3 changed files with 220 additions and 39 deletions
|
|
@ -37,7 +37,7 @@ async function uploadToS3(fileName: string, mediaUrl: string, maxRetry = 3) {
|
|||
}
|
||||
|
||||
const buffer = await response.arrayBuffer();
|
||||
|
||||
|
||||
// 2. Bun S3 Client만 사용하여 쓰기
|
||||
// client.write는 내부적으로 효율적인 스트리밍/버퍼 처리를 수행합니다.
|
||||
await client.write(fileName, buffer, {
|
||||
|
|
@ -67,4 +67,11 @@ async function uploadToS3(fileName: string, mediaUrl: string, maxRetry = 3) {
|
|||
throw lastError;
|
||||
}
|
||||
|
||||
export { makeS3FileName, uploadToS3, client as s3Client };
|
||||
async function writeToS3(fileName: string, data: ArrayBuffer | Blob, contentType: string) {
|
||||
await warmupS3();
|
||||
await client.write(fileName, data, {
|
||||
type: contentType,
|
||||
});
|
||||
}
|
||||
|
||||
export { makeS3FileName, uploadToS3, writeToS3, client as s3Client };
|
||||
Loading…
Add table
Add a link
Reference in a new issue