Skip to content

Attachments

zehavibarak edited this page Oct 27, 2022 · 1 revision

Storage

UseFileSystemFileStore(), UseDatabaseFileStore() or UseAzureFileStore().

Inline

<form [formGroup]=form>
    <bizdoc-file-upload multiple accept=".pdf" formControlName="license">
    </bizdoc-file-upload>
</form>
@Component(templateUrl: `my-component.component.html`)
export class MyComponent {
    readonly form = this._fb.group({
        license: this._fb.control(null)
    });
    constructor(private _fb: FormBuilder) {}
}

Inline attachments are private.

API

Properties

Name Usage
multiple Default. Boolean.
accept File extension, mime or global mime (image/*, etc.)

Attachment mode

Value Usage
Public Default.
Private Hidden from document header.
CheckedOut
CheckedIn

C#

public class MyBackend : FormBase<MyModel> {
    private readonly IDocumentContext _documentContext;
    public MyBackend(IDocumentContext documentContext) {
        _documentContext = documentContext;
    }
    public override Task UpdateAsync() {
        foreach(var attachment in _documentContext.Document.Attachments) {
            if(attachment.Mode.HasFlag(AttachmentMode.CheckedOut)) {
                ...
            }
        }
    }
}
public class MyModel {
    public int[] License { get; set; }
}

Use int as property type for single attachment or a collection of int for multiple.

Angular

export class MyComponent implements FormComponent<MyModel> {
    onBind(data: DocumentModel<MyModel>) {
        data.attachments.filter(a=> a.checkedOut).forEach( a=> ...);
    }
}
export interface MyModel {
 licensePapers: number[]
}

Intercept upload in form

public class MyBackend : FormBase<MyModel> {
    public override Task UploadAsync(MyModel model, IFormFile file) {
        ...
    }
}

Release Notes

Angular npm, Flutter pub.dev and Nuget packages.

Clone this wiki locally