Comments (9)
I haven't thought it through much yet. CFS does not have great built-in support for updating files at the moment, so I think I would probably use the same form with a hook to delete the existing avatar file once the new one is uploaded.
This pkg is really at more of a POC status right now. Seems to work fine, but I'm open to improvement ideas.
from meteor-cfs-autoform.
I created a fork and implemented an update behaviour there.
For every cfs-field, I fetch the corresponding property in the document that should be updated and delete the files, that had been attached to this property.
It's not tested well, in particular,I did not test it with fields that contain multipe files:
https://github.com/panter/meteor-cfs-autoform
from meteor-cfs-autoform.
How does it handle failure cases? That is, when are you deleting the files? Are you deleting the old files on a successful update and the new files on failure?
On Dec 12, 2014, at 6:07 AM, Marco Wettstein [email protected] wrote:
I created a fork and implemented an update behaviour there.
For every cfs-field, I fetch the corresponding property in the document that should be updated and delete the files, that had been attached to this property.It's not tested well, in particular,I did not test it with fields that contain multipe files:
https://github.com/panter/meteor-cfs-autoform—
Reply to this email directly or view it on GitHub.
from meteor-cfs-autoform.
Deleting files occure before inserting the new ones. So if insertion of a new file fails, the old files are deleted nevertheless. (by the way: i forget to push the current version, it should now be updated on the fork)
We could consider performing some kind of rollback: do not delete the files, but mark them as to be deleted. If insert of the new files succeed, delete the marked files.
from meteor-cfs-autoform.
I'm going to leave this one to @aldeed. Personally, I think we need to handle the failure cases slightly better in that a failure should put the database back to it's original state and not partially updated. For the apps I tend to work on, a failure could snowball into a disaster if I lose a file.
The other difficulty here is that we're trying to merge this project with another similar project that already has update capability. I'm hesitant to add more code into the mix and possibly create a more difficult merge of the codebases when it may be removed in favor of the other project's code anyway. Thus, I'm going to defer to @aldeed here.
Thanks for your work!
from meteor-cfs-autoform.
It is a prove-of-concept.
@aldeed, I am testing my fork currently and try to improve the failure-handling. It also needs refactoring. We might could merge back, if it is in a appropriate state. What do you think?
from meteor-cfs-autoform.
I think we can take the best of @macrozone and @yogiben update implementations and manually write a merged implementation into this package. I think @yogiben said his is fairly simple, adding/deleting the file immediately without waiting for form submission. Ideally we should support both ways, with the comprehensive rollback way being the default.
I would personally be interested in knowing more about specific use cases. When I handle updates, I tend to just handle them directly through CFS code, not as part of an update form. I think the main reason people are wanting this is for managing attached files in auto-CRUD like yogiben:admin. If that's true, then we should initially target toward that use case.
from meteor-cfs-autoform.
"Insert only" means if I update the form, without touching the file field, I would lose the uploaded files? And that file become dangling around? That's what happened to me on my form. After I update the form, the file field, which should be an _id of the file collection, becomes "dummyId".
Allowing updating is a very useful feature. I would love to see it implemented...
from meteor-cfs-autoform.
@sf-wind, yes probably, although there should be a way for us to make sure the "dummyId" doesn't make it through. I thought we were already doing that.
from meteor-cfs-autoform.
Related Issues (20)
- How do you add a before insert hook on this?
- Update for deeply nested cfs-file's broken HOT 2
- cfs-files (the multi version) does not work HOT 2
- Customize the ui "field" for multiple files
- this.template is undefined when before hook is a function HOT 1
- Exception in delivering result of invoking 'myServerMethod': Error: [[object Object]]
- file upload not working in IOS simulator
- Before hooks not work
- CfsAutoForm.Hooks.beforeInsert() is called, but after my Meteor.call() to save the form HOT 3
- Not a valid enum value HOT 1
- Error on the exemple code
- File Validation
- How to add an image preview to the update page? HOT 1
- how to display images of a array?
- Validation bug
- How to restrict file type?
- AutoForm 6.0 support. HOT 2
- How to subscribe cfs-files
- Incompatiple when adding cfs:autoform
- update form!!!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-cfs-autoform.