Can we search and find the big attachments?

AI-generated summary

@xiasummer is looking for a way to search and delete large attachments (bigger than 10M) in their Discourse forum due to limited server space. @codinghorror suggests that a data explorer query would be useful for this purpose.

@pfaffman recommends using the Unix find command to locate large files in the /var/discourse/shared/standalone/uploads directory. However, @xiasummer is hesitant to delete files manually due to concerns about accidentally deleting system components.

@pfaffman advises that only upload files are stored in the uploads directory, and suggests listing the files before deleting them. @Mittineague cautions that deleting attachments should be considered carefully, taking into account their potential usefulness.

@xiasummer clarifies that their concern is about accidentally deleting system files, not the attachments themselves. @pfaffman reassures them that only uploads are stored in the uploads directory.

@rishabh mentions that a data explorer query for this purpose has been added, which can be used to search for large attachments.

Your see, the server I rented is not very bid. And I find people like to upload attachments in the discourse. I have already set the maximum size of the attachments, while still the discourse Backup file is still too big.

Is it possible that I can search for the big attachments(say bigger than 10 M) and I can delete the attachment.

This would be a very useful canned data explorer query @rishabh.

If you’re OK with those links being broken, you can use the Unix find command to locate them in the uploads directory. Something like https://superuser.com/questions/628217/use-find-to-find-and-delete-large-files-of-a-certain-type

Is the upload folder

/var/discourse/shared/standalone/uploads

There are 2 subfolders in the “upload” folder, can I just delete things in the 2 subfolders?


Anyway, I still fell it too “dangerous” to delete things in this way.

Yes.

You’re breaking things on purpose, here.

You can see what would happen like this:

find /var/discourse/shared/standalone/uploads -type f -size +50000k -exec ls -lh {} \;

That’ll just list the files.

I’d recommend that you just leave them. It’s probably not that much space.

I wouldn’t be so concerned about how much space they’re taking up without considering their potential usefulness.

For example, if a topic had been archived, unlisted and had not been visited in a long time (i.e. the chances anyone might still be interested in the attachment are extremely rare) then I guess it might be OK to delete them. It would probably only impact members that were using the forum for long term file storage.

The word dangerous I mentioned is not I’m afraid of deleting the attachments, I’m actually afraid of miss deleting other files eapecially some system components that will kill the discourse system. If I can delete these attachments one by one, I will delete them.

Only uploads are in the uploads directory.

You’ll want to make a backup. :slight_smile:

The default query for it was added in DEV: Add a default query for Top 50 Largest Uploads · discourse/discourse-data-explorer@931bbb6 · GitHub and it looks like this: