pingdotgg / uploadthing

File uploads for modern web devs
https://uploadthing.com
MIT License
4.16k stars 307 forks source link

feat: enhance listFiles api to return additional fields #899

Open kuizuo opened 2 months ago

kuizuo commented 2 months ago

Describe the feature you'd like to request

I noticed that the files in the dashboard show size and uploaded.

image

but listFiles api doesn't have.

import { utapi } from "~/server/uploadthing.ts";

const files = await utapi.listFiles();

console.log(files);
/*
 * [
 *  {
 *    id: "7099d109-39ec-43fe-a887-4a4fd87cad88 ,
 *    customId: null, // whatever you set it to when uploading
 *    key: "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg",
 *    name: "image.jpg",
 *    status: "uploaded",
 *  }
 * ]
 */

Describe the solution you'd like to see

I want to use the metadata field to return this additional information. And through an option in the request body to decide whether to output

Additional information

No response

๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributing

markflorkowski commented 2 months ago

We kind of expect you to store that information in your own DB, listFiles being more of a backup method, hence why it does not return much info.

That said, after talking with the team, we are considering adding additional info to the return from this API. Do note however, we will likely be rate-limiting requests to this endpoint, as we still want to encourage storing this information on your own DB.

SrBrahma commented 1 month ago

@markflorkowski, would you recommend a simple cloud DB with a similar very easy setup for this info?

r0ld3x commented 1 month ago

@markflorkowski, would you recommend a simple cloud DB with a similar very easy setup for this info?

you can use supabase they provide PostgreSQL which is so easy to setup