Skip to content

MongocampBucketFiles

A dedicated file browser for one GridFS bucket: paginated, filterable, sortable table of the bucket's files (with clean FileInformation data — filename, size, upload date, metadata — no extended-JSON unwrapping needed), plus upload, download, delete, and rename/edit-metadata actions.

This is a second, purpose-built way to browse a bucket's files, alongside MongocampCollectionData's existing generic raw-document view of the <bucket>.files/<bucket>.chunks collections — that view is unchanged and still works; this component adds a cleaner, action-rich alternative scoped to a single bucket.

Usage

vue
<script setup>
const route = useRoute()
const bucketName = route.params.bucket_name
</script>

<template>
  <MongocampBucketFiles :bucket-name="bucketName" />
</template>

Typically reached via MongocampCollections's "Browse files" action on a bucket row (its bucketFilesPath prop, default /secured/admin/buckets) — the module doesn't own routing itself, so you provide the page that renders this component for a given bucket_name route param, matching the same pattern MongocampRoles' grantsPath uses for role grants.

Props

PropTypeDescription
bucketNamestringThe GridFS bucket to browse (no .files/.chunks suffix — the bare bucket name)

Columns

ColumnDescription
FilenameSortable
SizeSortable by the underlying byte length; displayed human-readable (B/KB/MB/GB/TB)
UploadedSortable by uploadDate; displayed via toLocaleString()
MetadataA "N keys" button opening a read-only JSON view when the file has metadata, otherwise
Download / rename / delete action buttons

Filtering, sorting, pagination

The filter input searches filename via a Lucene like expression (debounced, same convention as MongocampCollectionData). Sorting and pagination both refetch through useMongocampBucket's listFiles, which reads the total row count from the x-pagination-count-rows response header.

Actions

  • Download — reuses useMongocampBucket's downloadFile, tracked via downloadingFileIds
  • Rename / edit metadata — opens a FUDataEdit form (filename input + a nuxtUIRepeater of key/value pairs for metadata) and saves via updateFileInformation
  • Delete — behind a confirmation modal, calls deleteFile
  • Upload — toolbar button reusing uploadFile, refetches the table on success

All four actions are tracked via useMongocampBucket's own loading-state refs (downloadingFileIds, fileActionInFlight, uploading) and show success/error toasts from the composable itself — the component doesn't duplicate that feedback.

Released under the MIT License.