Replace Existing Files

Created on 23 July 2019, over 5 years ago
Updated 21 July 2023, over 1 year ago

Problem/Motivation

Rather than rename and bloat the filesystem on updated entities, consider replacement of existing files.

Steps to reproduce

See #3069511-09: Replace Existing Files β†’ .

Proposed resolution

Provide an option to replace, rather than rename, files.

Remaining tasks

Per #3069511-015: Replace Existing Files β†’ :

  1. Also, why not have a select or radios where you can choose how to handle existing files with the same name? EXISTS_RENAME, EXISTS_REPLACE or EXISTS_ERROR (prevent upload).

Original report

Might be nice to have an option to replace existing files rather than rename?

Patch incoming.

✨ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada drclaw

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Assigned to megachriz
  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States daniel-san

    This feature is EXACTLY what I've been looking for. Thank you for the work on this.
    Just tested with great success for file replacement. But, like previously stated by @chrisck in comment #29 ✨ Replace Existing Files Needs work , the generic file format for display on the field is showing the uploaded file name, but the url is linking to the tokenized file name and newly uploaded, different file. Which is really great!

    I am running Drupal 9.5.9

    File (Field) Paths - 1.0-beta6

    Used the patch from comment #39 ✨ Replace Existing Files Needs work

    Hoping to be able to help in getting new work tested and moved a bit forward. My small team is going to be at Drupalcon Pittsburgh this upcoming week and maybe there are others that want to join together to get this issue worked out.

  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

    Backtracking on my earlier comment, I'm not sure Filefield Paths is the right place to determine what should happen when a file already exists. It's a great module for specifying the desired location for a file, but it isn't responsible for initiating the upload.

    For example, Feeds β†’ allows you to specify whether to replace or rename an existing file. This choice isn't respected when using Filefield Paths.

    DropzoneJS also has its own logic and I expect other modules will as well.

    It's tricky because each module has its own configuration.

  • πŸ‡ΊπŸ‡ΈUnited States j-barnes

    Currently having issues where our content uploaders have two tabs open and have an attached document, and try to attach another document on the other tab (same node) it appends an underscore. This makes sense because the temp folder already has that file, but would be great if there was some type of warning. It looks like this would need to be changed at the file widget level though, and require something similar to the media entity file replace.

Production build 0.71.5 2024