Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename as a schema field #108

Open
JasonWeise opened this issue May 9, 2016 · 0 comments
Open

Filename as a schema field #108

JasonWeise opened this issue May 9, 2016 · 0 comments

Comments

@JasonWeise
Copy link

I am desperately trying to find a way to place the filename for the uploaded document as a field in the schema. Does anyone have any idea how to acheive this.
I'd like the user to select the file from autoform as usual and the filename from the selected file inserted into the relevant field.
Example schema..

Manual = new Mongo.Collection("manuals");
Manual.attachSchema(new SimpleSchema({
    section: {
        type: String,
        optional: false,
        label: "Section",
        allowedValues: ['Safety', 'Emergency Information']
    },originalfilename: {
        type: String,            <<--------------- I'd like to get the filename of the selected file into here
        optional: false,
        label: "Original Filename",
    },
    date:{
        type: Date,
        optional: false,
        label: "Date Updated",
        autoform: {
            type: 'hidden',
        },
        autoValue: function() {
            if (this.isInsert) {
                return new Date();
            } else if (this.isUpsert) {
                return {
                    $setOnInsert: new Date()
                };
            }else if (this.isUpdate) {
                return new Date();
            } else {
                this.unset();
            }
        }
    },
    document: {
        type: String,
        optional: false,
        autoform: {
            afFieldInput: {
                type: 'fileUpload',
                collection: 'Documents',
                label: 'Choose file',
                accept: '.pdf'
            }
        }
    }

If anyone has any idea that would be great... thanks heaps in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant