jijo-paulose / gwtupload

Automatically exported from code.google.com/p/gwtupload
Other
0 stars 0 forks source link

Uploader.setValidExtensions() doesn't update IFileInput's accept attribute properly #193

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. setup Uploader with default IFileInput.FileInputType.BROWSER_INPUT
2. call Uploader.setValidExtensions("csv");
2. open Uploader UI in the browser
3. check "Choose Files"form <input> attributes 

Expected: <input type="file".... accept=".csv"/>

Actual: <input type="file"... accept=""/>

What version of the product are you using? gwtUpload-1.0.0

On what operating system? Ubuntu 12.10

The problem is marked with **PROBLEM**:

public void setValidExtensions(String... extensions) {
    this.validExtensions = new ArrayList<String>();
    validExtensionsMsg = "";
    if (extensions == null || extensions.length == 0) {
      return;
    }
    List<String> v = new ArrayList<String>();
    String accept = "";
    for (String ext : extensions) {
      if (ext == null) {
        continue;
      }
      if (ext.contains("/")) {
        accept += (accept.isEmpty() ? "" : ",") + ext;
        continue;
      }
      if (!ext.startsWith(".")) ext = "." + ext;
      validExtensionsMsg += (validExtensionsMsg.isEmpty() ? "" : ",") + ext;
      ext = ext.replaceAll("\\.", "\\\\.");
      ext = ".+" + ext;
      validExtensions.add(ext);
    }

    ** PROBLEM: notice "accept" var only gets appended if ext.contains("/" ) above, so it'll be empty in the happy path **
    fileInput.setAccept(accept);
  }

Original issue reported on code.google.com by yap...@gmail.com on 17 Mar 2014 at 8:08

GoogleCodeExporter commented 8 years ago
Could you clone https://github.com/manolo/gwtupload, modify the code and send a 
patch? 

Thanks for reporting
- Manolo

Original comment by manuel.carrasco.m on 2 Apr 2014 at 8:34

GoogleCodeExporter commented 8 years ago
Fixed not released.
Use 1.0.2-SNAPSHOT in the meanwhile I release 1.0.2

Thanks for reporting

Original comment by manuel.carrasco.m on 7 Jan 2015 at 6:06

GoogleCodeExporter commented 8 years ago

Original comment by manuel.carrasco.m on 8 Jan 2015 at 6:16