Skip to content

@memberjunction/ng-file-storage

Angular components for managing file storage in MemberJunction applications, providing a complete file management system with category trees, file grids, upload with overwrite protection, and integration with MemberJunction’s pluggable storage providers.

The @memberjunction/ng-file-storage package provides three core components that together form a file management interface: a hierarchical category tree for organizing files, a Kendo Grid for browsing and managing files within categories, and an upload component with provider integration and overwrite protection. All file operations flow through MemberJunction’s entity system and storage provider abstraction, supporting Azure Blob Storage, AWS S3, and other backends.

flowchart TD
    subgraph UI["File Management UI"]
        CT[CategoryTreeComponent] --> FG[FilesGridComponent]
        FG --> FU[FileUploadComponent]
    end

    subgraph Operations["File Operations"]
        FU --> UPLOAD[Upload to Provider]
        FG --> DOWNLOAD[Download via Signed URL]
        FG --> DELETE[Delete with Confirmation]
        FG --> EDIT[Edit Metadata]
        CT --> CREATE[Create Category]
        CT --> DND[Drag & Drop Reorganize]
    end

    subgraph Backend["MJ Integration"]
        ENTITY[Entity Framework] --> GQL[GraphQL API]
        GQL --> PROVIDER[Storage Provider]
        PROVIDER --> AZURE[Azure Blob]
        PROVIDER --> S3[AWS S3]
    end

    Operations --> Backend

    style UI fill:#2d6a9f,stroke:#1a4971,color:#fff
    style Operations fill:#7c5295,stroke:#563a6b,color:#fff
    style Backend fill:#2d8659,stroke:#1a5c3a,color:#fff
Terminal window
npm install @memberjunction/ng-file-storage

Before using this package, ensure your MemberJunction database has:

  • File Storage Providers configured and active
  • File Categories entity permissions for users
  • Files entity permissions for users
  • GraphQL endpoints configured
import { FileStorageModule } from '@memberjunction/ng-file-storage';
@NgModule({
imports: [FileStorageModule]
})
export class YourModule { }
<div style="display: flex; height: 600px;">
<div style="width: 300px; border-right: 1px solid #ccc;">
<mj-files-category-tree
(categorySelected)="selectedCategoryId = $event">
</mj-files-category-tree>
</div>
<div style="flex: 1;">
<mj-files-grid
[CategoryID]="selectedCategoryId">
</mj-files-grid>
</div>
</div>
<mj-files-file-upload
[CategoryID]="selectedCategoryId"
(uploadStarted)="onUploadStarted()"
(fileUpload)="onFileUploaded($event)">
</mj-files-file-upload>
import { Component, ViewChild } from '@angular/core';
import { FilesGridComponent, FileUploadEvent } from '@memberjunction/ng-file-storage';
@Component({
selector: 'app-document-manager',
template: `
<div class="file-manager">
<div class="categories">
<mj-files-category-tree
(categorySelected)="onCategorySelected($event)">
</mj-files-category-tree>
</div>
<div class="files">
<mj-files-file-upload
[CategoryID]="selectedCategoryId"
(fileUpload)="onFileUploaded($event)">
</mj-files-file-upload>
<mj-files-grid #filesGrid
[CategoryID]="selectedCategoryId">
</mj-files-grid>
</div>
</div>
`
})
export class DocumentManagerComponent {
@ViewChild('filesGrid') filesGrid!: FilesGridComponent;
selectedCategoryId: string | undefined;
onCategorySelected(categoryId: string | undefined) {
this.selectedCategoryId = categoryId;
}
onFileUploaded(event: FileUploadEvent) {
if (event.success) {
console.log('Uploaded:', event.file.Name);
}
}
refreshFiles() {
this.filesGrid.Refresh();
}
}

CategoryTreeComponent (mj-files-category-tree)

Section titled “CategoryTreeComponent (mj-files-category-tree)”

Hierarchical tree view for managing file categories with drag-and-drop reorganization.

OutputTypeDescription
categorySelectedEventEmitter<string | undefined>Emitted when a category is selected
MethodDescription
createNewCategory()Opens dialog to create a category
deleteCategory(category)Deletes a category with error handling
handleDrop(e)Handles drag-and-drop to move categories
Refresh()Refreshes the category tree
clearSelection()Clears the current selection

Kendo Grid for displaying and managing files with inline editing.

InputTypeDefaultDescription
CategoryIDstring | undefinedundefinedCategory ID to filter files by
MethodDescription
downloadFile(file)Downloads file via provider’s signed URL
deleteFile(file)Deletes file with confirmation
saveEditFile()Saves changes to file metadata
resetEditFile()Cancels metadata editing
canBeDeleted(file)Checks if file can be deleted
Refresh()Refreshes the files grid

RecordAttachmentsComponent (mj-record-attachments)

Section titled “RecordAttachmentsComponent (mj-record-attachments)”

Slide-in drawer and standalone component for managing file attachments linked to specific entity records via MJ: File Entity Record Links and MJ: Files.

Features:

  • Slide-in & Resizable: Built on <mj-slide-panel> with UserInfoEngine width persistence.
  • Provider Filtering: Filter attachments across all configured cloud storage providers (Azure Blob, AWS S3, Box, etc.).
  • Dual View Modes: Card/Grid view with rich thumbnails and compact table/list view.
  • Drag-and-Drop Uploader: Direct upload pipeline with target storage account picker and signed token generation.
  • Rich Media Preview: In-app previews for PDFs, Images, Audio, Video, Code/Text, and Documents.
  • Cancelable Before/After Events: Full event lifecycle for uploads, deletions, unlinking, downloads, previews, and replacements.
  • Programmatic Verbs: Data model and action methods callable via code.
InputTypeDefaultDescription
RecordBaseEntity | undefinedundefinedEntity record to load/link attachments for
EntityIDstring | undefinedundefinedExplicit Entity ID (alternative to Record)
RecordIDstring | undefinedundefinedExplicit Record ID (alternative to Record)
AttachmentsRecordAttachmentItem[][]Direct data-bound array of attachment items
ConfigRecordAttachmentsConfigundefinedOptional configuration bag
VisiblebooleantrueWhether the slide panel is visible
ResizablebooleantrueWhether the panel is resizable
WidthPxnumber0Width in pixels (0 = restore from UserInfoEngine)
ViewMode'grid' | 'list''grid'Preferred view layout
AllowUploadbooleantrueWhether file uploading is enabled
AllowDeletebooleantrueWhether hard delete from storage is enabled
AllowUnlinkbooleantrueWhether unlinking from record is enabled
AllowDownloadbooleantrueWhether file download is enabled
AllowPreviewbooleantrueWhether in-app media preview is enabled
AllowReplacebooleantrueWhether replacing files is enabled
ShowProviderFilterbooleantrueShow filter pills when multiple providers are active
ShowSearchbooleantrueShow quick search filter
OutputTypeDescription
PanelClosedEventEmitter<void>Emitted when user closes the panel
WidthChangedEventEmitter<number>Emitted when panel is resized (auto-persisted)
AttachmentCountChangedEventEmitter<number>Emitted when attachments count changes
ViewModeChangedEventEmitter<AttachmentViewMode>Emitted when view mode toggles
BeforeUploadEventEmitter<BeforeUploadAttachmentEventArgs>Cancelable (event.Cancel = true) before upload begins
AfterUploadEventEmitter<AfterUploadAttachmentEventArgs>Emitted after files are uploaded and linked
BeforeDeleteEventEmitter<BeforeDeleteAttachmentEventArgs>Cancelable before an attachment is deleted
AfterDeleteEventEmitter<AfterDeleteAttachmentEventArgs>Emitted after an attachment is deleted
BeforeUnlinkEventEmitter<BeforeUnlinkAttachmentEventArgs>Cancelable before an attachment is unlinked
AfterUnlinkEventEmitter<AfterUnlinkAttachmentEventArgs>Emitted after an attachment is unlinked
BeforeDownloadEventEmitter<BeforeDownloadAttachmentEventArgs>Cancelable before download starts
AfterDownloadEventEmitter<AfterDownloadAttachmentEventArgs>Emitted after download URL is resolved
BeforePreviewEventEmitter<BeforePreviewAttachmentEventArgs>Cancelable before preview opens
AfterPreviewEventEmitter<AfterPreviewAttachmentEventArgs>Emitted after preview opens
BeforeReplaceEventEmitter<BeforeReplaceAttachmentEventArgs>Cancelable before file replacement begins
AfterReplaceEventEmitter<AfterReplaceAttachmentEventArgs>Emitted after file is replaced
MethodReturnsDescription
Refresh()Promise<void>Reloads attachments from server
UploadFiles(files, accountId?, categoryId?)Promise<RecordAttachmentItem[]>Uploads and links files programmatically
DeleteAttachment(item, hardDelete?)Promise<boolean>Deletes an attachment
UnlinkAttachment(item)Promise<boolean>Unlinks attachment from record
DownloadAttachment(item)Promise<boolean>Triggers secure download
PreviewAttachment(item)Promise<boolean>Opens media preview
ReplaceAttachment(item, newFile)Promise<RecordAttachmentItem | null>Replaces attachment with a new file
SetViewMode(mode)voidChanges view mode and persists preference
type FileUploadEvent =
| { success: true; file: FileEntity }
| { success: false; file: FileInfo };
  1. User selects a file through the upload component
  2. A preliminary file record is created in the MemberJunction system
  3. If a file with the same name exists, a confirmation dialog appears
  4. On confirmation, the file uploads to the active storage provider
  5. The file record status updates to “Uploaded”
  6. The fileUpload event emits with success status and file details
  • File deletion is restricted based on upload status and age (10 minutes for pending files)
  • Overwrite protection prompts users before replacing existing files
  • Download uses provider-specific signed URLs for security
  • Category drag-and-drop supports reorganizing the hierarchy
  • All operations include loading state indicators
PackageDescription
@memberjunction/coreCore metadata and entity access
@memberjunction/core-entitiesFile-related entity types
@memberjunction/globalGlobal utilities
@memberjunction/graphql-dataproviderGraphQL data operations
@memberjunction/ng-container-directivesContainer directives
@memberjunction/ng-sharedShared Angular services
@memberjunction/ng-shared-genericShared generic components
@progress/kendo-angular-gridData grid
@progress/kendo-angular-treeviewCategory tree
@progress/kendo-angular-uploadFile upload
@progress/kendo-angular-dialogConfirmation dialogs
@progress/kendo-angular-buttonsButton components
@progress/kendo-angular-dropdownsDropdown components
@progress/kendo-angular-indicatorsLoading indicators
@progress/kendo-angular-menuContext menu
  • @angular/common ^21.x
  • @angular/core ^21.x
  • @angular/forms ^21.x
  • @angular/router ^21.x
Terminal window
cd packages/Angular/Generic/file-storage
npm run build

Business Source License 1.1 — see LICENSE for details.