import { Upload } from "npm:@aws-sdk/lib-storage";
import { S3Client } from "npm:@aws-sdk/client-s3";
async function handleUpload({
file,
path,
contentType,
upsert,
}: UploadParams): Promise<string> {
try {
const text = "Hello, this is a test upload!";
const encoder = new TextEncoder();
const fileStream = encoder.encode(text);
const upload = new Upload({
client: s3Client,
params: {
Bucket: BUCKET_NAME,
Key: "testing/test.txt",
Body: fileStream,
ContentType: "text/plain",
},
});
console.log("Starting test upload...");
await upload.done();
console.log("Test upload completed successfully!");
} catch (error) {
console.error("Test upload failed:", {
name: error.name,
message: error.message,
stack: error.stack,
});
throw error;
}
}
import { Upload } from "npm:@aws-sdk/lib-storage";
import { S3Client } from "npm:@aws-sdk/client-s3";
async function handleUpload({
file,
path,
contentType,
upsert,
}: UploadParams): Promise<string> {
try {
const text = "Hello, this is a test upload!";
const encoder = new TextEncoder();
const fileStream = encoder.encode(text);
const upload = new Upload({
client: s3Client,
params: {
Bucket: BUCKET_NAME,
Key: "testing/test.txt",
Body: fileStream,
ContentType: "text/plain",
},
});
console.log("Starting test upload...");
await upload.done();
console.log("Test upload completed successfully!");
} catch (error) {
console.error("Test upload failed:", {
name: error.name,
message: error.message,
stack: error.stack,
});
throw error;
}
}