Giter Club home page Giter Club logo

Comments (9)

aldeed avatar aldeed commented on July 23, 2024

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.

macrozone avatar macrozone commented on July 23, 2024

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.

dpankros avatar dpankros commented on July 23, 2024

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.

macrozone avatar macrozone commented on July 23, 2024

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.

dpankros avatar dpankros commented on July 23, 2024

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.

macrozone avatar macrozone commented on July 23, 2024

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.

aldeed avatar aldeed commented on July 23, 2024

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.

sf-wind avatar sf-wind commented on July 23, 2024

"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.

aldeed avatar aldeed commented on July 23, 2024

@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)

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.