pingdotgg / uploadthing

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

feat: metadata field of file size #927

Open didinewlander opened 2 weeks ago

didinewlander commented 2 weeks ago

Describe the feature you'd like to request

when fetching a list of files I get only the URL, so the user can't actually show them what is the file size. This can cause some UX uninformative, especially for users with limited internet access asking to review the size of the file before triggering a preview or download of the file. Another use case is for server processing, the file size can affect the kind of process to handle that file

Describe the solution you'd like to see

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

const files = await utapi.listFiles();

console.log(files);
  [
 {
     id: "7099d109-39ec-43fe-a887-4a4fd87cad88 ,
     customId: null, 
     key: "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg",
     size: 10302 KB // or a MB format
     name: "image.jpg",
     status: "uploaded",
   }
 ]

Use Case - Dashboards

Well, while creating this issue I went back and forth across the API and the dashboard inorder to find where the size field could come in use, and it appears only in the dashboard, where I could review the file list, but if I wish to provide my client a similar dashboard - the size would come in handy.

Use Case - Storage Limit

Just like UT itself, I don't want my client to upload files with no limit - I need to be able to provide him with context about the overall space his files take in the system

Additional information

No response

👨‍👧‍👦 Contributing

markflorkowski commented 2 weeks ago

I'll bring this up with the team. Our design assumes you'd store the necessary data in your own database, which is typically faster than retrieving it via an API call—hence the minimal information returned by this API. That said, we've received similar requests for this functionality, so it's something we're considering.

cc @t3dotgg