vazco / uniforms

A React library for building forms from any schema.
https://uniforms.tools
MIT License
1.96k stars 244 forks source link

Integration with ostrio:files (Meteor-files) packages? #74

Closed vladejs closed 8 years ago

vladejs commented 8 years ago

Seems like Meteor-files package is the de facto package to upload files right now. It will be awesome a seamless integration with that package. Include examples in the docs, etc.

radekmie commented 8 years ago

I'm not willing to do such integrations inside this package, because it's not really form-related - if it's easy, then it doesn't have to be part of it, if it's hard - it's an additional thing to maintain. But even so, I would like to hear, what kind of integration would you like to see. If this will cover one field, we can easily create it here and then add it to the README.

serkandurusoy commented 8 years ago

I think this should be a separate package like most aldeed:autoform custom inputs and integrations are.

The implementation should not be too hard, it is basically a hidden input along with whatever upload markup/script is being used for ostrio:files and that input can be part of the schema.

connectField makes it very easy to wire up any standard input (input-like-component) with uniforms.

sabativi commented 8 years ago

I would rather say that this can be related to forms, there are tons of forms on internet where you need to upload a photo like an avatar. I think this could be a good functionnality to add here

radekmie commented 8 years ago

I understand, that it would be nice to have an all-in-one package, but I would rather go for a separate package. Even though, I want to know, what kind of integration would @vladejs like to have here.

mixcas commented 8 years ago

@vladejs I working on an upload field that uses Slingshot. You might find it useful. https://github.com/interglobalvision/applaya/blob/master/app/imports/components/fields/UploadField.jsx

I'm thinking i might do a separate package for it in the future.

macrozone commented 8 years ago

I also suggest to focus on a clean api that allows to implement custom fields.

Uniforms is already really good at this. We have know 2 projects where we rolled our own sets of components (non-bootstrap or whatever) and unforms did a great job.

We also implemented a slingshot-field (can't share yet), which is easy to do. I try to share if i have some spare time.

radekmie commented 8 years ago

I'm closing - we've all agreed, that creating custom field is not that hard, so there's no need for built-in integration.

vladejs commented 8 years ago

You are right, I created a custom field of type file. When it changes it bubbles the selected file up to the form component, so I can easily validate the file and upload to my server onSubmit event.

Thanx @radekmie.

dr-dimitru commented 7 years ago

Hi @vladejs , @radekmie

Came here from https://github.com/VeliovGroup/meteor-autoform-file/issues/17 Could we add examples for integration with uniforms to Meteor-Files? If, so could you point me to the right direction?

cyclops24 commented 7 years ago

Thanks @dr-dimitru and @radekmie , I'm follow this two issue for finding the right way for this integration. 😉 @radekmie Can you tell more about creating custom input type in uniform? Is it related to BaseField? Can you show me an example about creating custom input type in form? (It can be very useful, for example now for Meteor-Files and later for select2, map, ....)

radekmie commented 7 years ago

There is a lot of examples in the README.md. Also, many (even weird) fields were discussed in many issues - use the search, Luke.

macrozone commented 7 years ago

Hi guys, I have created a gist from one of our implementations of ostrio:files with uniforms.

It's build with mantra-architecture, but could also be used with few adjustments in other architectures. I stripped away unneeded stuff (styling..), but i hope you get the idea:

https://gist.github.com/macrozone/b2207c19aed0838d5982a09a5399dcae

edit: added resize function as well (may be useful)

edit2: i have a slingshot integration somewhere as well if anyone is interested (can be done similarly)

edit3: There is one caveat with this solution that you should be aware of: It uploads the file before the form is submitted. You might end up with several unused files on the server and should implement a cleanup-process that marks unused files.

andhdo commented 7 years ago

Hi; I have created a basic widget using the ostrio basic example, a similar code that you can find inside the Vulcan project for upload management (https://github.com/VulcanJS/Vulcan/blob/master/packages/vulcan-forms-upload/lib/Upload.jsx) and using the gist of @macrozone and @mixcas mixcas . It's not finished yet, but hope it helps.

https://gist.github.com/andhdo/8a88afa4390295c5e5f203c152cb0244

dr-dimitru commented 7 years ago

Hello @macrozone @andhdo ,

We would like to add your suggested usage to our wiki. Could you send a PR?

andhdo commented 7 years ago

Feel free to add the @andhdo contribution to your wiki. I think it is a little bit longer to include it as a pull request in the uniforms code (for example tests and improvements in the display of the widget and is not standardized to uniform widgets, because it uses the React.createClass mechanism for component creation).

adamczykjac commented 7 years ago

As a supplement to @macrozone and @andhdo gists, here's a minimal running project integrating those two packages and generating image-dropping form field out of a sample Simpl-Schema2 schema: https://github.com/adamczykjac/upload-image-uniforms.