UTApi (Server SDK) - getFileUrls with keyType equals "customId"

I'm using the ids of my products table as customId when saving the files, and I want to retrieve the urls using the id from my database, but the response returns an
data: readonly {
readonly key: string;
readonly url: string;
}[]
data: readonly {
readonly key: string;
readonly url: string;
}[]
I don't think I have a way to know the key with just the customId. I know there are alternatives, but I like the idea of having my product table like just the id and the name without having to save nothing from uploadthing and just use customId
const products = await ctx.db.select().from(productsTable).all();
const images = await utapi
.getFileUrls(products.map((p) => p.id), {keyType: "customId"})
.then((r) => r.data);
const products = await ctx.db.select().from(productsTable).all();
const images = await utapi
.getFileUrls(products.map((p) => p.id), {keyType: "customId"})
.then((r) => r.data);
Thanks
2 Replies
TerjaN
TerjaNOP7mo ago
Now you can get the file with
https://utfs.io/a/APP_ID/CUSTOM_ID
https://utfs.io/a/APP_ID/CUSTOM_ID
Deniz
Deniz6mo ago
if only i knew earlier!
Want results from more Discord servers?
Add your server