veliovgroup / meteor-autoform-file

Upload and manage files with #autoForm
https://github.com/veliovgroup/Meteor-Files
Other
39 stars 17 forks source link

Multiple files vs single files #3

Open Neobii opened 8 years ago

jankapunkt commented 6 years ago

There is a new development branch called multifile on which the multiple files upload has been implemented.

!!! Note, that the feature under construction and should not be used in production until review is finished and merged to master.

In order to allow multiple uploads you have to (switch to the branch, of course and) define the scheme in the following way:

new SimpleSchema({
  pictures: {
    type: Array,
    optional: true,
  },
  'pictures.$': {
    type: String,
    optional: true,
    label: false,
    autoform: {
      afFieldInput: {
        type: 'fileUpload',
        collection: 'Images',
        multiple: "multiple",
        // uploadTemplate: 'uploadField', // <- not working with custom templates yet!
        // previewTemplate: 'uploadPreview' // <- Optional
      }
    }
  }
}, {tracker: Tracker})

And create a quickForm like so:

{{> quickForm schema=multipleSchema id="uploadImages" type="normal" }}

Where multipleSchema is a helper which returns the above declared schema.

It uses a queue of files as Reactive variable outside of the template instances, so it is accessible on each file input field.

If the user selects multiple files the queue will be filled and the field templates will each fetch a file to upload.

If a single file is selected, the old behavior is executed (immediately upload the file).

A good extension would be to make the queue-ing accessible to custom templates or document for custom templates how to realize multiple uploads.

mishantidev commented 6 years ago

I added this two specified schema fields to my existent schema, and here is my form tag: quickForm collection=productsCollection doc=product id="updateProductForm" type="update"

However, delete button doesn't delete fields from array, preview doesn't works right as well, showing same image for different objects!

Also, if afFieldType is 'fileUpload', why there is mention of non-existent template 'fileUploads' in autoform.js? Is it just an unfinished and not working properly prototype?

jankapunkt commented 6 years ago

Thanks a lot for the investigation. I will look into it and update the branch accordingly.

jankapunkt commented 6 years ago

I added this two specified schema fields to my existent schema, and here is my form tag: quickForm collection=productsCollection doc=product id="updateProductForm" type="update"

However, delete button doesn't delete fields from array, preview doesn't works right as well, showing same image for different objects!

I have created an experimental repo, which we can use as foundation for discussion: https://github.com/jankapunkt/meteor-autoform-multiles-example

Can you confirm, that the unwanted behavior also appears there?

(P.s. you need to clone this repo into a packages folder, since I wanted to avoid the submodules-mess)

Also, if afFieldType is 'fileUpload', why there is mention of non-existent template 'fileUploads' in autoform.js? Is it just an unfinished and not working properly prototype?

This dead reference is to be removed just now, thank you.

jankapunkt commented 6 years ago

@anjunatic did you check into the repo?

jankapunkt commented 5 years ago

@dr-dimitru did you have time to check into the repo? If you like it, I would make it a bit more robust and create a PR for review.

jankapunkt commented 5 years ago

Please keep open, new PR coming in within the next days.

dr-dimitru commented 5 years ago

@jankapunkt 10.4

jankapunkt commented 4 years ago

There is a new updated PR in this feature: https://github.com/VeliovGroup/meteor-autoform-file/pull/58