CustomElement-DropFiles icon indicating copy to clipboard operation
CustomElement-DropFiles copied to clipboard

Is there a prop that we can use for previously uploaded files ?

Open chihebnabil opened this issue 4 years ago • 2 comments

Hello Guys !

Hope that you are doing well!

Is there a prop that can we use to inject an array of links or files to be able to preview them ?

It's useful when you are building edit forms because the user will probably want to see what he already uploaded otherwise this field will be empty as by default

Kind regards

chihebnabil avatar Jul 19 '21 15:07 chihebnabil

It's not supported (since the original input file cannot have a default value. But it's doable to add this feature, i'm not sure how the API would look

Grafikart avatar Jul 19 '21 21:07 Grafikart

@Grafikart thanks you reply i have cloned the project in my local env and tried to add a prop called data

type Props = {
  help: string
  label: string,
  data : Array<String>
}

& I also added a function that reads a function that reads an image from a file and convert it to a file Like this

 private async  createFile(url): Promise<any> {
    let response = await fetch(url);
    let data = await response.blob();
    let metadata = {
      type: 'image/jpeg'
    };
    let file = new File([data], "test.jpg", metadata);
    return file;
  }
}
 <input
            type="file"
            multiple
            name="files[]"
            label="Drop files here or click to upload."
            help="Upload files here and they won't be sent immediately"
            is="drop-files"
            data="['https://imgur.com/gallery/cKpLVTS']"
    /> 

What do you think about this solution isn't suitable?

Kind regards

chihebnabil avatar Jul 23 '21 14:07 chihebnabil