Use Lytebox (a Lightbox clone) for quick viewing images.
[pithos] / src / gr / ebs / gss / client / FileUploadGearsDialog.java
index e70a71a..25203a8 100644 (file)
@@ -39,6 +39,7 @@ import com.google.gwt.gears.client.httprequest.HttpRequest;
 import com.google.gwt.gears.client.httprequest.ProgressEvent;\r
 import com.google.gwt.gears.client.httprequest.ProgressHandler;\r
 import com.google.gwt.gears.client.httprequest.RequestCallback;\r
+import com.google.gwt.http.client.URL;\r
 import com.google.gwt.json.client.JSONObject;\r
 import com.google.gwt.json.client.JSONString;\r
 import com.google.gwt.user.client.Command;\r
@@ -354,15 +355,10 @@ public class FileUploadGearsDialog extends FileUploadDialog implements Updateabl
 \r
                String path;\r
                final String filename = getFilename(file.getName());\r
-               FileResource selectedResource = getFileForName(filename);\r
-               if (selectedResource == null ) {\r
-                       // We are going to create a file.\r
-                       path = folder.getUri();\r
-                       if (!path.endsWith("/"))\r
-                               path = path + "/";\r
-                       path = path + encodeComponent(filename);\r
-               } else\r
-                       path = selectedResource.getUri();\r
+               path = folder.getUri();\r
+               if (!path.endsWith("/"))\r
+                       path = path + "/";\r
+               path = path + encode(filename);\r
 \r
                String token = app.getToken();\r
                String resource = path.substring(app.getApiPath().length()-1, path.length());\r
@@ -421,4 +417,15 @@ public class FileUploadGearsDialog extends FileUploadDialog implements Updateabl
                GSS.get().showFileList(true);\r
                GSS.get().getStatusPanel().updateStats();\r
        }\r
+\r
+       /**\r
+        * Same as URL.encode, but also encode apostrophe since browsers aren't\r
+        * consistent about it (FF encodes, IE does not).\r
+        */\r
+       private String encode(String decodedURL) {\r
+               String retv = URL.encode(decodedURL);\r
+               retv = retv.replaceAll("'", "%27");\r
+               return retv;\r
+       }\r
+\r
 }\r