Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » "Replace File" option for Files & Images

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1355 Views
  • Hello_electro
    Avatar
    Community Member
    80 Posts

    "Replace File" option for Files & Images Link to this post

    So in the CMS if I have a photo uploaded, I can "replace with one from my computer"

    Can this be done with Files? For example, if I update a file (say a form). Shouldnt there be an option to replace the file? I cant seem to make this happen.

    Any thoughts? Am I missing something? I do have Uncle Cheese's DOM installed. Maybe something there?

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: "Replace File" option for Files & Images Link to this post

    BUMP!

    I can see that the File class has updateLinks() http://api.silverstripe.org/default/File.html#updateLinks - but can't find any way to update the actual filesystem file via the Files & Images admin and then fire off this updateLinks() for the selected File entry in the db.

    Once an admin has a bunch of links everywhere directed to a particular File, if they need to update the pdf (for example) they have to upload a new File via the admin and then go to all the pages referring to the old File and change the links.. ? That can't be right can it?

    What have I missed?

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: "Replace File" option for Files & Images Link to this post

    Still nothing on this?

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: "Replace File" option for Files & Images Link to this post

    This functionality is part of the versioned files module - you can grab it from http://github.com/ajshort/silverstripe-versionedfiles. In the Filest & Images area, when you click on the edit button for a file a new Replace tab will show up.

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: "Replace File" option for Files & Images Link to this post

    Outstanding! Thanks ajshort, I'll be giving this a go very shortly. Do you know if it's 2.4rc1 compatible?

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: "Replace File" option for Files & Images Link to this post

    I'm getting a few errors, firstly after /dev/build/ I tried to run /dev/tests/ but got

    [Warning] copy(/path/to/website/root/www/assets/Uploads/_versions/12/Kids-2B1.ssets/uploads/kids-2b): failed to open stream: No such file or directory
    GET /dev/tasks/FileVersionCreationTask

    And if I now try to open the Files & Images Admin I get

    [User Error] FieldSet::addFieldToTab() Tried to add a tab to object 'FieldSet' - 'BottomRoot' didn't exist.

    eek! I'm running close to if not the latest 2.4. Any suggestions?

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: "Replace File" option for Files & Images Link to this post

    Ah, the first error was the result of that file not actually having an extension in its filename in the db.

    Still getting the error relating to the BottomRoot tab not existing though. Going hunting now, but any suggestions welcome.

  • dizzystuff
    Avatar
    Community Member
    93 Posts

    Re: "Replace File" option for Files & Images Link to this post

    Unfortunately for my current timelines this appears a little too buggy out of the box.

    Removed the no-extension file and changed references to "BottomRoot" tab to "Root" tab but then got the following when viewing a File and trying to replace it:

    Viewing the file, versions drop down screenshot is attached.

    Replacing the file,

    [User Notice] Upload::setAllowedExtensions() is deprecated. Please use Upload_Validator::setAllowedExtensions() instead

    Happy to help with some testing along the way but I can't use it in production just yet.

    Cheers
    Dizzy

    Attached Files
    1355 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.