Code Monkey home page Code Monkey logo

meteor-autoform-file's Introduction

Autoform File

Description

Upload and manage files with autoForm.

Meteor autoform file

Maintained by Meteor Factory. Professional Meteor development.

Meteor autoform file

Quick Start

  1. Install meteor add yogiben:autoform-file

  2. Create your collectionFS (See collectionFS)

@Images = new FS.Collection("images",
  stores: [new FS.Store.GridFS("images", {})]
)
  1. Make sure the correct allow rules & subscriptions are set up on the collectionFS
Images.allow
  insert: (userId, doc) ->
    true
  download: (userId)->
    true

and

Meteor.publish 'images', ->
  Images.find()

and in your router.coffee

  @route "profile",
    waitOn: ->
      [
        Meteor.subscribe 'images'
      ]
  1. Define your schema and set the autoform property like in the example below
Schemas = {}

@Posts = new Meteor.Collection('posts');

Schemas.Posts = new SimpleSchema
  title:
    type: String
    max: 60

  picture:
    type: String
    autoform:
      afFieldInput:
        type: 'fileUpload'
        collection: 'Images'
        label: 'Choose file' # optional

Posts.attachSchema(Schemas.Posts)

The collection property is the field name of your collectionFS.

  1. Generate the form with {{> quickform}} or {{#autoform}}

e.g.

{{> quickForm collection="Posts" type="insert"}}

or

{{#autoForm collection="Posts" type="insert"}}
{{> afQuickField name="title"}}
{{> afQuickField name="picture"}}
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}

###Multiple images### If you want to use an array of images inside you have to define the autoform on on the schema key

Schemas.Posts = new SimpleSchema
  title:
    type: String
    max: 60

  pictures:
    type: [String]
    label: 'Choose file' # optional

  "pictures.$":
    autoform:
      afFieldInput:
        type: 'fileUpload',
        collection: 'Images'

###Security & optimization### The above example is just a starting point. You should set your own custom allow rules and optimize your subscriptions.

Customization

You can customize the button / remove text.

Defaults:

{{> afFieldInput name="picture" label="Choose file" remove-label="Remove"}}

Also it is possible to customize accept attribute

add it in your schema definition:

picture:
  type: String
  autoform:
    afFieldInput:
      type: 'fileUpload'
      collection: 'Images'
      accept: 'image/*'
      label: 'Choose file' # optional

Upload progress bar

By default FS.UploadProgressTemplate from cfs:ui package is used to display upload progress. You can specify your own template with uploadProgressTemplate option, e.g.

picture:
  type: String
  autoform:
    afFieldInput:
      type: 'fileUpload'
      collection: 'Images'
      uploadProgressTemplate: 'myUploadProgressTemplate'

Custom file preview

Your custom file preview template data context will be:

  • file - FS.File instance
  • atts - autoform atts
picture:
  type: String
  autoform:
    afFieldInput:
      type: 'fileUpload'
      collection: 'Images'
      previewTemplate: 'myFilePreview'
<template name="myFilePreview">
  <a href="{{file.url}}">{{file.original.name}}</a>
</template>

Custom select/remove file buttons

Remember to add js-af-select-file and js-af-remove-file classes to nodes which should fire an event on click.

picture:
  type: String
  autoform:
    afFieldInput:
      type: 'fileUpload'
      collection: 'Images'
      selectFileBtnTemplate: 'mySelectFileBtn'
      removeFileBtnTemplate: 'myRemoveFileBtn'
<template name="mySelectFileBtn">
  <button type="button" class="js-af-select-file">Upload file</button>
</template>

<template name="myRemoveFileBtn">
  <button type="button" class="js-af-remove-file">Remove</button>
</template>

Callbacks

onBeforeInsert - can be used to modify file (remember to return fileObj)

onAfterInsert - called after insert with two arguments: error object and file object

Please note that callback properties are functions that return callbacks. This is because autoform evaluates function attributes first.

picture:
  type: String
  autoform:
    afFieldInput:
      type: 'fileUpload'
      collection: 'Images'
      onBeforeInsert: ->
        (fileObj) ->
          fileObj.name 'picture.png'
          fileObj
      onAfterInsert: ->
        (err, fileObj) ->
          if err
            alert 'Error'
          else
            alert 'Upload successful'

meteor-autoform-file's People

Contributors

bastiaanterhorst avatar captainn avatar christianbundy avatar hosseinagha avatar jfols avatar markleiber avatar martunta avatar mpowaga avatar peernohell avatar yogiben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meteor-autoform-file's Issues

Autosave doesn't trigger when in an array.

When using in an array like so

CollectionSchema = new SimpleSchema({
  images: {
    type: [String],
    optional: true
  },
  'images.$': {
    type: String,
    autoform: {
      type: "fileUpload",
      collection: "Images"
    }
  }
});

Auto save doesn't trigger when a file is added, or removed.

do something after upload

I want to store the images in a base64 string, not in a cfs. Is it possible in the current version?

uploaded image is not display when form is for update

hi there,

thanks for the package! uploading images works great

when I open the form for update (using QuickForm) image(s) (name, etc.) is not there only a placeholder and the Remove button, I'm using an array:

    'patient.images': {
        type: Array,
        optional: true
    },
    'patient.images.$': {
        type: Object
    },
    'patient.images.$.name': {
        type: String,
        autoform: {
            afFieldInput: {
              type: 'fileUpload',
              collection: 'Images'
            }
        }
    },

do I need to do some extra, perhaps with CollectionFS, so the already uploaded image gets displayed?

thanks for your support!

tinto

resetting the form when using a string collection name breaks the form

The fix for #9 breaks the form when resetting validation using AutoForm.resetForm, as this will reset the data context to its original values.

I could take a look at fixing this, but I'm not sure what hooks would be best to use. As far as I can tell, there isn't a specific hook that gets triggered when validation is reset.

image is not displayed (create/update)

I think I ran into an issue, just updated my project with your latest package version

  1. at initial upload of an img

I get this error

Exception in template helper: TypeError: undefined is not a function
    at Object.Template.afFileUpload.helpers.fileUpload (http://localhost:3000/packages/yogiben_autoform-file.js?a20c1c1a1bd39c2df31e8a4eb576720dab7d7d28:285:24)
  • img not displayed
  • img uploaded fine
  1. open form for update with the img uploaded at step 1
  • img not displayed
  • same error msg
  1. do an upload/choose file again
  • img is displayed after file dialog
  • after submit same error msg

less 2.5.0 compatibility

Hello!

I tried to install yogiben:autoform-file in meteor 1.2-rc.7, but got message about less package:

meteor add yogiben:autoform-file
=> Errors while adding packages:

While selecting package versions:
error: Conflict: Constraint [email protected] is not satisfied by less 2.5.0-rc.2_1.
Constraints on package "less":

Maybe it's possible to detect meteor version in package.js and change required less version?

Constraint on package "less" preventing update to Meteor 1.2.0.1

Update to Meteor 1.2.0.1 is failing due to conflicting LESS version. This is the full error message:

$ meteor update
Update to release [email protected] is impossible:
While selecting package versions:             
error: Conflict: Constraint [email protected] is not satisfied by less 2.5.0_2.
Constraints on package "less":
* less@=2.5.0_2 <- top level
* [email protected] <- yogiben:autoform-file 0.2.9

This project is at the latest release which is compatible with your current package constraints.
Your top-level dependencies are at their latest compatible versions.

The following top-level dependencies were not updated to the very latest version available:
 * yogiben:autoform-file 0.2.9 (1.0.1 is available)

Newer versions of the following indirect dependencies are available:
 * babrahams:editable-json 0.4.3 (0.6.0 is available)
 * meteorhacks:meteorx 1.0.2 (1.3.1 is available)
 * sanjo:karma 1.7.0 (2.0.0 is available)     
 * softwarerero:accounts-t9n 1.0.9 (1.1.4 is available)
To update one or more of these packages, pass their names to `meteor update`.

Is there an immediate solution or does this package need to change its LESS dependency?

Edit: Actually a copy of #56

Values of array of images not removed on '-'

Images are correctly removed with the 'x Remove' button, but if i click on the '-' button and after query for the values, then re-add the image to the array, the array length outputs as 3 when it should be 2.

Show upload progress

Thanks for the great package, works like a charm.

However, UX-wise, I think the upload progress should be shown to the user. Has anyone tried to build this or to integrate a package for this?

Error: AutoForm: No component found for rendering input with type "fileUpload"

Broken when using cordova?

When implementing your file uploads in my meteor app, everything works fine so far but once I deploy my app to mobile (Android) devices, clicking the upload button doesn't do anything. Is meteor-autoform-file not intended to be used on cordova based mobile apps?

accept="image/*"

I have been trying to change plugin to do accept="image/*" on input button, but to no avail.
It is always hard to properly restyle the file chooser button, but in this case it seems that you have chosen the way that is not working well with extra attributes like accept="image/*"

or maybe I am wrong? And there is a way?

Otherwise I think there might be better ways how to restyle the button - for example I have used something like this before:

.btn-file {
    position: relative;
    overflow: hidden;
}
.btn-file input[type=file] {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 100%;
    min-height: 100%;
    font-size: 100px;
    text-align: right;
    filter: alpha(opacity=0);
    opacity: 0;
    outline: none;
    background: white;
    cursor: inherit;
    display: block;
}

and with html:

<span class="form-control btn btn-primary btn-file">
  <input type="file" accept=".xlsx">Select .xlsx file to upload</input>
</span>

and then I could add accept attribute, and it worked with restyled button.
But maybe there is a way how to do it with existing code?
If not, then I will do a plugin version with changes to css and also to make accept attribute configurable as well, and then send a pull request.

Multi-file select feature

Autoform file is awesome! But the interface for selecting multiple files could be better. Is there a way to get an interface to do multiple file selection at once, instead of having to add a field for each new file? Maybe an interface like JQuery File Upload?

Wrong Version Published to Atmosphere?

Having a bit of an issue figuring out what's up with the version of this package right now. Seems like something is out of sync somewhere, assuming that we're working off the master branch and not develop (which had a version bump recently, but not sure why?).

tl;dr: I think the develop branch might have accidentally got version-bumped and pushed to atmosphere.

abernix@host:~/Dev/Project (master)$ meteor update
yogiben:autoform-file               0.2.7* File upload for AutoForm

* New versions of these packages are available! Run 'meteor update' to try to update those packages to their latest versions. If your packages cannot be updated further, try typing
  `meteor add <package>@<newVersion>` to see more information.

So, after an meteor update, it's still there, saying there's an upgrade... Okay, let's see what's up - the git repo master branch just got a bump to 0.2.8, so...

abernix@host:~/Dev/Project (master)$ meteor add yogiben:[email protected]
 => Errors while parsing arguments:           

While adding package yogiben:[email protected]:
error: no such version yogiben:[email protected]

Hmm... no such version 0.2.8? Let's look at Atmosphere...

screen shot 2015-08-01 at 10 02 39 pm

Ok, looks like a weird jump from 0.2.7 to 1.0.1... but I'll try it...

abernix@host:~/Dev/Project (master)$ meteor add yogiben:[email protected]
 => Errors while adding packages:             

While selecting package versions:
error: Conflict: Constraint aldeed:[email protected] is not satisfied by aldeed:autoform 5.3.2.
Constraints on package "aldeed:autoform":
* aldeed:[email protected] <- abernix:autoform-semantic-ui 0.4.5
* aldeed:[email protected] <- yogiben:autoform-file 1.0.1

Yea... something seems out of pitch. Did the develop branch get accidentally bumped and published to atmosphere? 👀

Files never deleted?

I'm trying this module for the first time. It seems that the files in the database is never deleted. Here is what I did.

I create a form, attach a file to it, submit. The file is attached nicely. Great.
Then I update the form, click "remove" to remove the original file. Then attach a different file, submit. The new file is attached. Great.
Then I go into the mongodb database to search file records in cfs.files.filerecord collection. I find that the original file is still in the database.

The first thing I can think of is that I don't have remove permission defined correctly. But I have identical permissions for insert and remove:

Files.allow
download : ->
true
insert : (userId, file) ->
Roles.userIsInRole(userId, ['admin'])
update : (userId, file) ->
Roles.userIsInRole(userId, ['admin'])
remove : (userId, file) ->
Roles.userIsInRole(userId, ['admin'])

Did I do something wrong when using this package?

File update issue.

App broken? This package has recently undergone some app-breaking changes in light of autoform's recent updates. To fix, define your schema as in the tutorial below and replace your afFileUpload templates with afQuickField. Sorry for any inconvenience caused.

concerned about the above problem. Issue is, not able to update the file and fix mentioned above also could not helped on this. Can you please let me know when the complete working package can be expected?

Thanks

UX detail - filename displayed when no image is uploaded

hi,

is there any way to display the short file name: "Capture_Drop_Down.xlsx" instead of

/cfs/files/patientFiles/6AALn5zQxwaes35do/Capture_Drop_Down.xlsx?token=eyJhdXRoVG9rZW4iOiJWUzhJcThmbkJGcWxBWmFMTzFQMFNZLW1fdGlCeENNb2dUMDhVRi1iZ0J5In0%3D"?

clicking on the name nothing happens, is it a bug?

thanks for your support!

regards,

tinto

Question: Is it possible to not use CollectionFS?

I was wondering if I really need to upload/store the image some where in order to use this package. All I really want to do is display a user selected image in the form, and keep the path (of course). I would like to handle the persistence of the images later, together with my form.

I thought I could trick the package by not setting the collection option or using a dummy collection, but failed miserably. Am I approaching this sideways?

Thanks in advance!

remove data

hi , i'm new here , how can i remove data in database ? thank you for advance .

Support for EJSON

Is it possible to store the EJSON with entire FS.file object directly instead of reference ID?

I would like to store entire object or image URL directly to have it loaded only with one DB Request.

Image array inside an array

I am trying to make a quickform for an array og images inside and array and the quickform renders a regular text input.

This is my code schema code (sorry for coffescript):

project: type: [Object]
'project.$.name':
type: String
label: 'Name'
'project.$.description':
type: String
label: 'Description'
'project.$.pictures':
type: [String]
label: 'Choose file'
'project.$.pictures.$'
autoform:
afFieldInput:
type: 'fileUpload'
collection: 'images'

{{#autoForm collection="OSB.Companies" id="insertMicrosite" type="insert"}}


{{> afQuickField name="project"}}

{{/autoForm}}

Thanks for your help!

How do I render the image in Meteor?

Hello,

So I've got my meteor-admin all setup now but I'm just wondering how I actually display the image?

for example:

    .image: img( src="#{image}" )

If I do it like this though it just renders the _id of the image I created...

Thanks.

Input doesn't show

No input for file upload but that appear in the console:

"Exception in template helper: getTemplateName@http://localhost:3000/packages/aldeed_autoform.js?e71f561d26e90711b8a4ddf6136073fdffff296d:6945:1
bindDataContext/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2880:14
Blaze._wrapCatchingExceptions/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1651:14
wrapHelper/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2928:14
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12
wrapHelper/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2927:1
Spacebars.call@http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:172:12
Template.afFieldInput</<@http://localhost:3000/packages/aldeed_autoform.js?e71f561d26e90711b8a4ddf6136073fdffff296d:6906:17
Blaze._TemplateWith/wrappedArgFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2795:14
Blaze.With/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2599:26
viewAutorun/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1865:16
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12
viewAutorun/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1864:1
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:12
viewAutorun@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1863:1
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:327:5
Tracker.Computation@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:243:5
Tracker.autorun@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:566:11
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1875:14
Blaze.With/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2598:7
fireCallbacks@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1941:9
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12
Blaze._fireCallbacks/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1938:5
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:12
Blaze._fireCallbacks@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1937:3
Blaze._createView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1955:3
Blaze._materializeView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1998:3
materializeDOMInner@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1476:9
Blaze._materializeDOM@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1428:7
doMaterialize@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2017:32
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12
doRender@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2015:9
viewAutorun/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1865:16
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12
viewAutorun/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1864:1
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:12
viewAutorun@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1863:1
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:327:5
Tracker.Computation.prototype._recompute@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:346:9
Tracker._runFlush@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:485:9
onGlobalMessage@http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:372:11
" meteor.js:888:10
"Exception in template helper: afFieldInputContext@http://localhost:3000/packages/aldeed_autoform.js?e71f561d26e90711b8a4ddf6136073fdffff296d:6988:1
bindDataContext/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2880:14
Blaze._wrapCatchingExceptions/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1651:14
wrapHelper/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2928:14
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12
wrapHelper/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2927:1
Spacebars.call@http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:172:12
Template.afFieldInput</<@http://localhost:3000/packages/aldeed_autoform.js?e71f561d26e90711b8a4ddf6136073fdffff296d:6907:13
Blaze._TemplateWith/wrappedArgFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2795:14
Blaze.With/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2599:26
viewAutorun/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1865:16
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12
viewAutorun/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1864:1
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:12
viewAutorun@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1863:1
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:327:5
Tracker.Computation@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:243:5
Tracker.autorun@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:566:11
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1875:14
Blaze.With/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2598:7
fireCallbacks@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1941:9
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12
Blaze._fireCallbacks/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1938:5
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:12
Blaze._fireCallbacks@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1937:3
Blaze._createView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1955:3
Blaze._materializeView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1998:3
materializeDOMInner@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1476:9
Blaze._materializeDOM@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1428:7
doMaterialize@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2017:32
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12
doRender@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2015:9
viewAutorun/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1865:16
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12
viewAutorun/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1864:1
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:12
viewAutorun@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1863:1
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:327:5
Tracker.Computation.prototype._recompute@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:346:9
Tracker._runFlush@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:485:9
onGlobalMessage@http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:372:11
"

I updated all packages to last version but it doesn' t seem to help.

Upload not working. Console shows warning.

I'm getting this warning in the console when uploading a file. i'm using it inside the yogiben:admin dashboard.

http-call-client.js:101 - The provided value 'undefined' is not a valid enum value of interface XMLHttpRequestResponseType.

Any ideas? Edit: added my code and some comments below.

lib/collections/images.js

Images = new FS.Collection('images', {
    stores: [new FS.Store.FileSystem('images', {path: '~/uploads'})]
});

if (Meteor.isServer) {
    Images.allow({
        insert: function (userId, doc) {
            return !! userId;
        },

        update: function (userId, doc, fieldNames, modifier) {
            return !! userId;
        },

        remove: function (userId, doc) {
            return !! userId;
        }
    });
}

server/publish.js

Meteor.publish('images', function () {
    return Images.find();
});

lib/collections/posts.js

Posts = new Mongo.Collection('posts');
Posts.attachSchema(new SimpleSchema({
    ...
    pictures: {
        type: [String],
        label: 'Choose file'
    },
    'pictures.$': {
        autoform: {
            afFieldInput: {
                type: 'fileUpload',
                collection: 'Images'
            }
        }
    }
}));

I followed the instructions for the multiple images. But I skipped the subscription and the auto-form part. since i assume that's handled by the yogiben:admin package, cmiiw.

UPDATE:

I've added the "Images" collection to the admin configuration but it throws an error.

lib/config.js

AdminConfig = {
    name: 'Project Name',
    adminEmails: ['[email protected]'],

    collections: {
        Posts: {
            icon: 'file-text-o'
        },
        // added this line
        Images: {
            icon: 'file-image-o'
        }
    }
};

With this message in the console:

W20150718-23:27:28.036(7)? (STDERR) /Users/rizky/.meteor/packages/meteor-tool/.1.1.3.8ctqri++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150718-23:27:28.036(7)? (STDERR)                         throw(ex);

W20150718-23:27:28.037(7)? (STDERR)                               ^

W20150718-23:27:28.085(7)? (STDERR) Error: Tabular.Table options must specify collection

W20150718-23:27:28.085(7)? (STDERR)     at new Tabular.Table (packages/aldeed:tabular/common.js:20:1)
W20150718-23:27:28.086(7)? (STDERR)     at packages/yogiben:admin/lib/both/startup.coffee:101:27
W20150718-23:27:28.086(7)? (STDERR)     at Function._.each._.forEach (packages/underscore/underscore.js:113:1)
W20150718-23:27:28.086(7)? (STDERR)     at adminCreateTables (packages/yogiben:admin/lib/both/startup.coffee:77:4)
W20150718-23:27:28.086(7)? (STDERR)     at __coffeescriptShare (packages/yogiben:admin/lib/both/startup.coffee:185:2)
W20150718-23:27:28.086(7)? (STDERR)     at /Users/rizky/Sites/apta/helpyourbody/app/.meteor/local/build/programs/server/boot.js:229:5

=> Exited with code: 8

How to use on the server side to create dummy data?

Hi, Thanks for the package. It seems to work great.
I am trying to create some dummy data.

From your example below, how can I insert picture from server side files for dummy posts that I create?

Schemas = {}

@Posts = new Meteor.Collection('posts');

Schemas.Posts = new SimpleSchema
    title:
        type:String
        max: 60

    picture:
        type: String
        autoform:
            afFieldInput:
                type: 'fileUpload'
                collection: 'Images'
        label: 'Choose file' # optional

Posts.attachSchema(Schemas.Posts)

Error while form gets rendered

The fileUpload field never gets rendered. I got this error:

Error: Unexpected object in htmljs in toText: [object Object]

My Schema looks like this:

Schemas.Forms.UserProfile = new SimpleSchema({
  profile : {
    type : Object
  },
  'profile.name' : {
    type : String
  },
  'profile.description' : {
    type : String,
    optional : true
  },
  'profile.picture' : {
    type : String,
    autoform : {
      aFieldInput : {
        type : 'fileUpload',
        collection : 'Images',
        label : 'Upload'
      }
    }
  }
});

When I remove the Field Template

{{> afQuickField name="profile.picture"}}

from my template file the error does not appear.

My hole form Template looks like this:

<Template name="admin_profile">

  {{#autoForm schema="Schemas.Forms.UserProfile" id="edit_user_profile" type="method" meteormethod="user:edit-profile" doc=user}}
  <div class="row">

    <div class="col-sm-6">
      {{> afQuickField name='profile.name'}}
    </div>
    <div class="col-sm-4">
      {{> afQuickField name="profile.picture"}}
    </div>
    <div class="col-sm-8">
      {{> afQuickField name='profile.description'}}
    </div>

  </div>
    <div class="row">
      <div class="col-xs-6">
        <br />
        <button type="submit" class="btn btn-primary subscribe-plus-one-activity">Save</button>
      </div>
    </div>
  {{/autoForm}}
</Template>

What could this be ?

Blaze rendering issue .

Hello ,

Everything was fine until , i got this error in the browser console :

Error: AutoForm: No component found for rendering input with type "fileUpload"


Exception in template helper: Error: AutoForm: No component found for rendering input with type "fileUpload"
    at Object.afFieldInputContext (http://localhost:3000/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:6979:13)
    at bindDataContext (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2727:16)
    at Blaze._wrapCatchingExceptions (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1606:16)
    at Object.Spacebars.call (http://localhost:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:171:18)
    at http://localhost:3000/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:6898:23
    at Blaze._TemplateWith.wrappedArgFunc (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2639:14)
    at null.<anonymous> (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2445:26)
    at http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1808:16
    at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12)
    at viewAutorun (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1807:18)

It doesn't seem to work with cfs-s3

I could use this package with cfs-grid, but when I tried to transition to cfs-s3, it throws an error when selecting a file to upload:

PUT http://localhost:3000/cfs/files/files/i5JrZ4kbZQkoYcNJc?chunk=0&filename=ca…VG9rZW4iOiI3RVlOcUxQclVVcnJldDY2NGpSdDh1TVdlTl9Sdl9OLS01Vlp2MnVxNjIyIn0%3D 503 (Service Unavailable) at http-call-client.js:198
 Error: "Queue" failed [503] Error in method "/cfs/files/:value/:value/", Error: Error: FS.TempStore.Storage is not set: Install cfs:filesystem or cfs:gridfs or set it manually     at mount... [undefined], Error: failed [503] Error in method "/cfs/files/:value/:value/", Error: Error: FS.TempStore.Storage is not set: Install cfs:filesystem or cfs:gridfs or set it manually     at mount... [undefined]
    at upload-http-client.js:33
    at http-call-client.js:69
    at _.once (underscore.js:750)
    at XMLHttpRequest.xhr.onreadystatechange (http-call-client.js:192)

Any idea why? is this package designed to work with cfs-s3?

Block autoform submission while uploading files

With the latest commit (636a2a0), it shows "Uploading..." while the file is uploading, but we can submit the autoform that's holding the plugin, not saving the file id and messing up with everything.

It would be nice if we could prevent that form submission. Maybe setting a flag on each instance and stopping form submission event propagation if that flag is set on "uploading"?

Preview image not reactive to document change.

When the doc parameter of the autoForm changes, child afQuickFields should update accordingly. However, the fileUpload preview image does not react. Clicking the Reset button seems to force a refresh and the expected preview image is displayed. Is this as intended?

In the following example, the title (text input) will correctly update when theactiveSlide helper changes, but the background (fileUpload) preview image does not change until the Reset button is clicked.

{{#autoForm id="form_editSlide" collection="Slides" doc=activeSlide}}
  {{> afQuickField name="title"}}
  {{> afQuickField name="background"}}
  <button type="submit" class="btn btn-primary">Submit</button>
  <button type="reset" class="btn btn-default">Reset</button>
{{/autoForm}}

how to change default uploaded label

hi ,

i love this package , it working as expected when working with image upload , but it seem i cant change the label when working with non image files , eg: pdf
it always show "/cfs/files/blabla" after i choose file to upload.

is there anyway i can customize what to show on that label?

thanks for help and great package .

Is it possible to change upload button?

Hello friends,

I am trying to change the upload button and instead of a classic button I want it to be an image. Is it possible to do this?

Thank you very much.

FR: multiple upload

im trying to create multiple inputs to upload images, but when i try to instantiate a autoform it gives me String inputs, not image inputs.

"photoGallery": {
        type: [String],
        label: "Bus - photo gallery",
        optional: true,
        autoform:{
            afFieldInput:{
                type: 'fileUpload',
                collection: 'Images'
            }
        }
    }

{{> afQuickField name='photoGallery' }}

is that currently possible?

License?

Could you add an open source license to this project?

Spelling error

This is a very minor issue, or I wouldn't even call it a issue, but I figured I should post it here. On the atmosphere page for the package, the readme heading says "Autofom File" instead of "Autoform File"

Unable to update...

When using a autoform to update a collection like so:
{{> quickForm collection="MediaCollection" doc=updateMediasingle id="updateMediaForm" type="update"}}

And defining a doc in a template helper:
Template.editmedia.helpers({
updateMediasingle: function() {
return MediaCollection.findOne({_id: $stateParams.mediaID});
}
});
I'm getting:
Exception in template helper: TypeError: collection.findOne is not a function
at Object.Template.afFileUpload.helpers.fileUpload /yogiben_autoform-file.js?:285:24)

It fails to load the image on first render but does load it after I hit submit on the update form..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.