Minh Techie
Minh Techie
Explore posts from servers
HHono
Created by Minh Techie on 1/27/2025 in #help
Image uploaded to S3 cannot be displayed when run on Lambda
Thanks! I will try this one
20 replies
HHono
Created by Minh Techie on 1/27/2025 in #help
Image uploaded to S3 cannot be displayed when run on Lambda
I have no idea 😅 I’ve tried Google, Gpt but nothing works. I guess I have to use something else
20 replies
HHono
Created by Minh Techie on 1/27/2025 in #help
Image uploaded to S3 cannot be displayed when run on Lambda
20 replies
HHono
Created by Minh Techie on 1/27/2025 in #help
Image uploaded to S3 cannot be displayed when run on Lambda
what do you mean? the type is jpeg
20 replies
HHono
Created by Minh Techie on 1/27/2025 in #help
Image uploaded to S3 cannot be displayed when run on Lambda
@ambergristle 1. the image is uploaded successfully but when I view it it says The image cannot be displayed because contains error 2. yes it's correct. Here's what I see in CloudWatch
FormData {
banner: '',
profile_img: File {
size: 311948,
type: 'image/jpeg',
name: 'cat.jpg',
lastModified: 1737954587729
},
name: "My Channel",
description: 'This is My channel',
id: '...'
}
FormData {
banner: '',
profile_img: File {
size: 311948,
type: 'image/jpeg',
name: 'cat.jpg',
lastModified: 1737954587729
},
name: "My Channel",
description: 'This is My channel',
id: '...'
}
3. I tried c.parseBody but still no luck
20 replies
HHono
Created by Minh Techie on 1/27/2025 in #help
Image uploaded to S3 cannot be displayed when run on Lambda
S3Service
const S3Service = {
uploadFile: async (file: File) => {
if (!bucketName || !region) {
throw new Error("Missing required bucket name and region");
}

const fileId = v4();

const fileExtension = file.name.split(".").pop();
const fileKey = `${fileId}.${fileExtension}`;

const arrayBuffer = await file.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);

const params = {
Body: buffer,
Bucket: bucketName,
Key: fileKey,
ContentType: file.type,
};

const uploadCommand = new PutObjectCommand(params);
const response = await s3Client.send(uploadCommand);

if (!response) return "Failed to upload file";

const url = `https://${bucketName}.s3.${region}.amazonaws.com/${fileKey}`;
return url;
},
};
const S3Service = {
uploadFile: async (file: File) => {
if (!bucketName || !region) {
throw new Error("Missing required bucket name and region");
}

const fileId = v4();

const fileExtension = file.name.split(".").pop();
const fileKey = `${fileId}.${fileExtension}`;

const arrayBuffer = await file.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);

const params = {
Body: buffer,
Bucket: bucketName,
Key: fileKey,
ContentType: file.type,
};

const uploadCommand = new PutObjectCommand(params);
const response = await s3Client.send(uploadCommand);

if (!response) return "Failed to upload file";

const url = `https://${bucketName}.s3.${region}.amazonaws.com/${fileKey}`;
return url;
},
};
20 replies
HHono
Created by Minh Techie on 1/27/2025 in #help
Image uploaded to S3 cannot be displayed when run on Lambda
ChannelService.updateChannel
async function updateChannel(channelId: string, formData: FormData) {
let profileImgUrl: string = "";
let bannerUrl: string = "";

const profileImg = formData.get("profile_img");

if (profileImg && typeof profileImg === "object" && "name" in profileImg) {
profileImgUrl = await S3Service.uploadFile(profileImg);
}

const bannerImg = formData.get("banner");

if (bannerImg && typeof bannerImg === "object" && "name" in bannerImg) {
bannerUrl = await S3Service.uploadFile(bannerImg);
}

// logic to update the channel info in the DB
return updatedChannel;
}
async function updateChannel(channelId: string, formData: FormData) {
let profileImgUrl: string = "";
let bannerUrl: string = "";

const profileImg = formData.get("profile_img");

if (profileImg && typeof profileImg === "object" && "name" in profileImg) {
profileImgUrl = await S3Service.uploadFile(profileImg);
}

const bannerImg = formData.get("banner");

if (bannerImg && typeof bannerImg === "object" && "name" in bannerImg) {
bannerUrl = await S3Service.uploadFile(bannerImg);
}

// logic to update the channel info in the DB
return updatedChannel;
}
20 replies
DTDrizzle Team
Created by Minh Techie on 12/13/2024 in #help
TypeError: Cannot read properties of undefined (reading 'replace')
and here's drizzle.config.ts. The database url is correct
import { defineConfig } from "drizzle-kit";

export default defineConfig({
dialect: "postgresql",
schemaFilter: ["public"],
introspect: {
casing: "preserve",
},
schema: "./src/db/schema",
out: "./supabase/migrations",
dbCredentials: {
url: process.env.DATABASE_URL ?? "",
},
});
import { defineConfig } from "drizzle-kit";

export default defineConfig({
dialect: "postgresql",
schemaFilter: ["public"],
introspect: {
casing: "preserve",
},
schema: "./src/db/schema",
out: "./supabase/migrations",
dbCredentials: {
url: process.env.DATABASE_URL ?? "",
},
});
3 replies
DTDrizzle Team
Created by Minh Techie on 12/13/2024 in #help
TypeError: Cannot read properties of undefined (reading 'replace')
Here's my schema
3 replies
DTDrizzle Team
Created by Minh Techie on 9/18/2024 in #help
drizzle-kit generate doesn't run custom sql
thanks it works now
4 replies
HHono
Created by Jackson Kasi on 5/2/2024 in #help
Seeking Guidance: Transitioning from Hono.js with Cloudflare Workers to AWS Lambda
I have the same problem. The document is poorly written
3 replies
CDCloudflare Developers
Created by Stockton on 4/5/2024 in #workers-help
✘ [ERROR] Failed to register worker in local service registry TypeError: fetch failed
same for me. I'm using Wrangler ^3.47.0 in a Hono app @Stockton have you found the fix?
5 replies