Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Random string as a filename to allow uploading the same image name #147

Description

@AlexGach

Hi,
If a user uploads a second image named as a previously uploaded image, first image disappear and generates 404 error. For example uploading "default.png" in several articles.

To solve this we are using shorId library to generate a random value (like ECOMMERCE>ORDERS).

                  <image keyName="backimage" title="Upload your image" 
                        uiParams={{
                          filename: shortId.generate()
                        }}
                      />

The problem is that shortId.generate() returns always the same value.
How can we use shortID for uiParams filename correctly?
Thanks!

Activity

  1. abz53378 commented on Feb 19, 2019

    @abz53378
    Contributor

    Hi, thanks for your report, currently the filename only support fixed string. So what if we support the function in filename property, like this:

    <image keyName="backimage" title="Upload your image" 
      uiParams={{
        filename: (file) => {
           // you also can get the origin file from argument
           return `${file.name}${shortId.generate()}`
        }
      }}
    />
  2. AlexGach commented on Feb 19, 2019

    @AlexGach
    Author

    Hi @abz53378, that would be great 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions