uploadthing icon indicating copy to clipboard operation
uploadthing copied to clipboard

feat: enhance listFiles api to return additional fields

Open kuizuo opened this issue 1 year ago โ€ข 3 comments

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

  • [X] ๐Ÿ™‹โ€โ™‚๏ธ Yes, I'd be down to file a PR implementing this feature!

kuizuo avatar Jul 31 '24 08:07 kuizuo

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.

markflorkowski avatar Aug 05 '24 18:08 markflorkowski

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

ftzi avatar Sep 11 '24 14:09 ftzi

@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

r0ld3x avatar Sep 11 '24 15:09 r0ld3x